PHP problem PHP problem
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

PHP problem

Started by pedro84, December 25, 2006, 11:55:12 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

pedro84

Welcom Everyone!
I got big problem:
I changed in include/init.inc.php
define('TEMPLATE_FILE', 'template.html');
to
define('TEMPLATE_FILE', 'template.php');
It works. I neeed my template to be php file;)

But php in template.php doesn't work:|
Hmm... I tried even to test and <?php echo "TEST"; ?> doesn't work. Has anyone got any idea?

Joachim Müller

Changing the name of the template file doesn't do anything, it doesn't make PHP parsed in that file. The name could be anything. Turn it back to how it used to be (template.html).
You can't have PHP in the template file directly. Use the placeholder tokens instead ({CUSTOM_HEADER} and {CUSTOM_FOOTER} instead. If you have got them running and need more, feel free to add them.
Instead of trying to accomplish something that can't be done because of the way Coppermine works I suggest that you tell us instead what bit of PHP code you want to see parsed in which spot.

pedro84

The main problem is that I use somethink like this:
?module=Guestbook&lang=".$currentlang."

How to aplly this in my gallery?

I'm a special kind of php newbie;) I try everything to make by myself and in 80% I did;)

Joachim Müller

So what you actually want to do is add a custom link to coppermine's menu that points to your guestbook with the currenty language of the visitor as a parameter?
To add a custom link to Coppermine's menu you'll have to edit themes/yourtheme/theme.php (not template.html) - this is being covered in many postings already. Posting a link to your coppermine-driven gallery might be a good start. Zip your custom theme and attach it to your posting (using "additional options" when composing your message).


pedro84

I just edited classic theme. Over the main table I put my header, and above - my footer. But i have something like this
[oryginally] eg.
<a class="hide" href="#" title="Home"><img src="images/menu/home<?php ".$currentlang."?>.png" class="link1" alt="Home" /></a>
and I don't now how to make it working in templates.

I "integrated" gallery with my site this way, cause its unable to use include or require.
I need only - I think - to define $currentlang in theme.php?

pedro84

I found this, http://www.bullseyephotos.com/blog/?p=40 but now  I get T_DOUBKE_ARROW error

Joachim Müller

Quote from: GauGau on December 25, 2006, 12:32:37 PM
Posting a link to your coppermine-driven gallery might be a good start.


pedro84


Gizmo

What is it exactly that you to accomplish by adding php code to your gallery?
Did you read the manual first???? Taking 2 minutes to backup your files can save you hours of wondering what you screwed up.
Billy Bullock - BullsEyePhotos Blog of Indecision

pedro84

I will have functional menu which contains php code. It's a bit important ;D Menu from my layout, not menu in coppermine. I can't imagine not using coppermine on my site;) If I'm thinking good I can replace php by {TAG}? But when I try in my theme.php i get Double_T Error.

Nibbler


pedro84


<li><a href="index.php?module=biography&lang=<?php ".currentlang." ?> title="">Fixed 3</a></li>


This is part from the menu.

Joachim Müller

That's pseudo-code that won't do anything. You'll have to echo/print your output. The var that get's populated by Coppermine is $CONFIG['lang'].
Subsequently, your code should be something like
echo '<li><a href="index.php?module=biography&lang=' $CONFIG['lang'] . '" title="">Fixed 3</a></li>';

pedro84

Quote from: pedro84 on December 28, 2006, 09:09:22 AM

<li><a href="index.php?module=biography&lang=<?php ".currentlang." ?> title="">Fixed 3</a></li>


This is part from the menu.

I meant this is link from my template menu. I have integreted gallery by making custom footer and header. Now I need to put php code to template.

Ok. Where to put code You wrote?:>

Joachim Müller

As suggested: edit themes/yourtheme/theme.php as you see fit. There are loads of threads on this sub-board that deal with modifying the coppermine menus. Pay particular attention to the sticky threads.

pedro84

Ok. But I think You don't understand me a bit:)

Ok. Here we go.
This is my template.html file:


<html>
<head>
[i]MY header HERE[/i]
<script type="text/javascript" src="scripts.js"></script>
<!-- $Id: template.html 2688 2005-12-04 03:22:35Z donnoman $ -->
</head>
<body>

<div id="container">

<div id="logo">
[i]MY logo HERE[/i]
</div>


<div id="menu">
[i]MY MENU HERE[/i]

</div>


</div>
  <table width="100%" border="0" cellpadding="20" cellspacing="20">
    <tr>
      <td valign="top" style="background-color:transparent;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="100%" align="center">
              <h1>{GAL_NAME}</h1>
              <h3>{GAL_DESCRIPTION}</h3><br />
              {SYS_MENU} <br /> {SUB_MENU}
            </td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="center" valign="top">
              {LANGUAGE_SELECT_FLAGS}
            </td>
          </tr>
          <tr>
            <td align="center" valign="top">
              {THEME_SELECT_LIST}
              {LANGUAGE_SELECT_LIST}
            </td>
          </tr>
        </table>
        <img src="http://michael-schenker.com/images/spacer.gif" width="1" height="15" alt="" />
        <br />
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td align="left" valign="top">
              {ADMIN_MENU}
              {GALLERY}
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>

<div id="footer">
[i]MY FOOTER HERE[/i]
</div>





</div>
</body>




Ok. Correct me if I'm thinking bad. Is it good way to integrate gallery with my site?

Main question:
My menu works perfectly on main page. But When I have integrated gallery with my site I have lost possibility to use php. I tried to define {TAG} in theme.php but I got DOUBLE_ARROW [or something similar] error. I just want to modify my header menu, not menu from coppermine. I only want to define just one tag:) This damned lang;)

Hope now You understand me;) [or I don't understand You;)]

Joachim Müller

You can't use PHP in template.html, that's why anything PHPish needs to go into theme.php. So basically, you might do as suggested and add a custom placeholder token (the stuff in curly brackets). You then have to define the content that is suppossed to replace the placeholder token as the theme is being parsed by modifying the pageheader function. If you're not sure how to accomplish this, then zip your custom theme and attach it to your next posting (using "additional options" when composing your message) and I'll look into it.

However, what you're up to do is exactly what the {CUSTOM_HEADER} token is suppossed to do - you can specify a path to your custom include file (that would include your overall site navigation in your case) for that very purpose in Coppermine's config. Take a look at our demo - basically that's what I did there with the blue overall menu and the advanced theme and languages selectors.

As I suggested though: the code you posted wouldn't do anything, it's just wishful thinking. Not related to Coppermine, but to how PHP works - yours just isn't proper PHP syntax, so it won't do what you expect it to do.

pedro84

Quote from: GauGau on December 28, 2006, 06:09:55 PM
You can't use PHP in template.html, that's why anything PHPish needs to go into theme.php. So basically, you might do as suggested and add a custom placeholder token (the stuff in curly brackets). You then have to define the content that is suppossed to replace the placeholder token as the theme is being parsed by modifying the pageheader function. If you're not sure how to accomplish this, then zip your custom theme and attach it to your next posting (using "additional options" when composing your message) and I'll look into it.

However, what you're up to do is exactly what the {CUSTOM_HEADER} token is suppossed to do - you can specify a path to your custom include file (that would include your overall site navigation in your case) for that very purpose in Coppermine's config. Take a look at our demo - basically that's what I did there with the blue overall menu and the advanced theme and languages selectors.

As I suggested though: the code you posted wouldn't do anything, it's just wishful thinking. Not related to Coppermine, but to how PHP works - yours just isn't proper PHP syntax, so it won't do what you expect it to do.


Could You write somethink how to set custom header? I did it wrong way. Hmmm...it would be enough. Custom header and custom footer :-\

pedro84