PHP inside theme.php? PHP inside theme.php?
 

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 inside theme.php?

Started by gelaskimgel, August 25, 2006, 12:31:41 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gelaskimgel

Hey... My question is:

Why I can't add some php code inside this fx:

// Template used for Vanity Footer
$template_vanity = <<<EOT
<div id="vanity">
      <a id="v_php" href="http://www.php.net/"  rel="external"></a>
      <a id="v_mysql" href="http://www.mysql.com/"  rel="external"></a>
      <a id="v_xhtml" href="http://validator.w3.org/check/referer"  rel="external"></a>
      <a id="v_css" href="http://jigsaw.w3.org/css-validator/check/referer"  rel="external"></a>
</div>
EOT;


If I'm fx going to write:

// Template used for Vanity Footer
$template_vanity = <<<EOT
<div id="vanity">
<? include("test.php"); php ?>
</div>
EOT;


then the output is: <? include("test.php"); php ?>

why is it not possible to add php code inside the field?

Nibbler


gelaskimgel

Is it possible to make it valid for PHP? or make the Gallery system valid... so that it could read fx template.php instead off template.html?

Joachim Müller

If you're going to add PHP code, you need to understand code. Yours is just wishfull thinking. You could add PHP there, but that's not the recommended solution. We could post the code that is syntax-wise correct, but you would probably complain if it didn't do what it's suppossed to do. Note that you can not use any code: the output your code generates needs to fit in.
If you want to add a custom footer, do as suggested in the docs: there's a {CUSTOM_FOOTER} token that will include your custom php file. All you need to do is entering the relative path into the corresponding section of the config page (as suggested in "Path to custom footer include"). In your case, you just enter "test.php" (without the quotes) if test.php resides within the root of your coppermine folder.

gelaskimgel

ok, that's great... but where is I'm going to add "test.php" which file? I'm not sure that I did understand what you meant

Joachim Müller

...nor did I understand your reply. Let's start from the beginning: post a link to your existing file "test.php" and a link to your coppermine-driven gallery.
As you seem to be lacking basic skills, I recommend trying to come up with an alternative: what is test.php suppossed to do? Describe in detail what you're trying to accomplish. Maybe we can come up with a solution that doesn't require you to use PHP at all.

gelaskimgel

the test.php is printing out the picture of the day by this code:

<?php
/*
+--------------------------------------------------------------------------
|   Image period Mod by Des Hooper 
|   ========================================
|   Web: http://www.pinguish.co.uk
|   Email: mod@pinguish.co.uk
+---------------------------------------------------------------------------
| Do not remove this link data - credit where due please
+--------------------------------------------------------------------------
*/
//***Enter Path information here*** 
//***absolute path to main coppermine directory*** 

$copperminepath '../../';  //***YOU MUST CHANGE THIS*** 

//This connects to the mysql DB 
//***change username and password below*** 

$MZrandompic = @mysql_connect('localhost''xxxxxxxxxxx''xxxxxxxxxxxxx'); //***YOU MUST CHANGE THIS*** 

if (!$MZrandompic) {  
echo( 
'<p>Unable to connect to the ' .  
'database server at this time.' );  
exit();  
}  

//select photo DB 


if (! @mysql_select_db('xxxxxxxxxxx') ) {//***YOU MUST CHANGE THIS***  
die( 'Unable to locate the picture ' .  
'database at this time.' );  
}  
function 
all_ims() {
//This gets a random picture record from the database and 
//the picture's location and displays it 
//***title of the page is here so can me made day/week/month etc**
//***YOU MUST CHANGE THIS*** 
$MZresult = @mysql_query("SELECT  * 
FROM cpg148_pictures , cpg148_imageperiod
WHERE cpg148_imageperiod.pid = cpg148_pictures .pid AND date < now( ) order by cpg148_imageperiod.powid DESC Limit 10"
);  
if (!
$MZresult) {  
die(
'Error performing query: ' mysql_error() .  
'');  
}  

while ( 
$MZrow mysql_fetch_array($MZresult) ) {  

// $albumid = $MZrow{'aid'};  //This gets the picture's associated album name 
$pos $MZrow{'pid'};      //This finds the picture's coppermine location 
$ownername =$MZrow{'owner_name'}; 
$dd=$MZrow{'date'};
$uploaded =date("d F Y",strtotime("$dd"));   
echo(
'<div ALIGN=left>');  
//***YOU MUST CHANGE THIS*** note path to the gallery must follow your path convention
echo('<a  href="../../displayimage.php?album=' $albumid .  
'&pos=-' $pos '">'); //make thumbnail clickable 
//***YOU MUST CHANGE THIS*** note path to the gallery must follow your path convention
echo('<IMG height="200" width="114" SRC="../../albums/');           //append base dir structure 
echo($MZrow{'filepath'}.thumb_.$MZrow{'filename'} . 
     
'" alt="click HERE to comment or get more info on the image"''border=0 >' '</a>'); //outputs path from /userspics 
}  
}
function 
im() {
//This gets a random picture record from the database and 
//the picture's location and displays it 

$MZresult = @mysql_query("SELECT * 
FROM cpg148_pictures, cpg148_imageperiod
WHERE cpg148_imageperiod.pid = cpg148_pictures.pid AND date < now() order by cpg148_imageperiod.powid DESC LIMIT 1"
);  
if (!
$MZresult) {  
die(
'<p>Error performing query: ' mysql_error() .  
'');  
}  

while ( 
$MZrow mysql_fetch_array($MZresult) ) {  

// $albumid = $MZrow{'aid'};  //This gets the picture's associated album name 
$pos $MZrow{'pid'};      //This finds the picture's coppermine location 
$ownername =$MZrow{'owner_name'};  
$dd=$MZrow{'date'};
$uploaded =date("d F Y",strtotime("$dd"));     
echo(
'<div ALIGN=left>');  
$ownerid =$MZrow{'owner_id'};  
//***YOU MUST CHANGE THIS*** note path to the gallery must follow your path convention
echo('<a  href="../../displayimage.php?album=' $albumid .  
'&pos=-' $pos '">'); //make thumbnail clickable 
//***YOU MUST CHANGE THIS*** note path to the gallery must follow your path convention
echo('<IMG height="200" width="114" SRC="../../albums/' );           //append base dir structure 
echo($MZrow{'filepath'}.$MZrow{'filename'} . 
     
'" alt="click HERE to comment or get more info on the image" ''border=0 >' '</a>'); //outputs path from /userspics 
}  
}

if (
$_GET{'id'}== "history") { all_ims();
}
else { 
im();
}



?>




And I wan't it to show up her, where you can see the picture: http://www.rdc.lir.dk/index.php?theme=neweb
But I'm now using an I-frame, but it does not fit into the design... Så I want to use the php code inside the template.html og inside the theme.php so the picture could fit in the design, and the result would look good... Hope you understand what I mean...

Joachim Müller

That's exactly what I was afraid of: you're trying to do tricky stuff without having an idea what you're doing. You can't open another mySQL connection in mid-air. And it's obviously not necessary, as a connection is already open and established that you could use.

You haven't done as I suggested:
Quote from: GauGau on August 25, 2006, 06:12:32 PMpost a link to your existing file "test.php"
, so I can't help you.

Take my advice: try doing something you're capable of - your skill level isn't sufficient for what you're trying to do. I'm not trying to be rude, this is just my advice. If you know your way around using <iframes>, then use them.

gelaskimgel


gelaskimgel

I don't understand what you mean with post a link to your existing file "test.php" . Do you want me too write http link to the test.php on this forum? or do you want me to post a link to me existing file "test.php" inside the gallery? If yes, where?

Joachim Müller

Quote from: gelaskimgel on August 25, 2006, 08:43:30 PM
I don't understand what you mean with post a link to your existing file "test.php"
You already did what I wanted you to do in your previous posting.

If you're going to heed my advice, drop the whole idea, as this won't work as expected. However, if you want to learn things the hard way, you'd have to enter
Quotethemes/neweb/test.php
into "Path to custom footer include" (as suggested in one of my previous postings
Quote from: GauGau on August 25, 2006, 05:34:41 AM
If you want to add a custom footer, do as suggested in the docs: there's a {CUSTOM_FOOTER} token that will include your custom php file. All you need to do is entering the relative path into the corresponding section of the config page (as suggested in "Path to custom footer include").
). Please don't even bother to reply: this doesn't work, I get an error message saying "XXX" - you have been warned.

gelaskimgel

ok GauGau... but I still does not understand what you mean with this:
All you need to do is entering the relative path into the corresponding section of the config page (as suggested in "Path to custom footer include"). In your case, you just enter "test.php" (without the quotes) if test.php resides within the root of your coppermine folder.

Which config page are you talking about.... In which file does I have to enter this: themes/neweb/test.php and in which line of that file?

gelaskimgel

ok GauGau I did understand you now :)

gelaskimgel

GauGau you can close the question... everything is working now :)