Advanced search  

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

Pages: [1]   Go Down

Author Topic: PHP inside theme.php?  (Read 6781 times)

0 Members and 1 Guest are viewing this topic.

gelaskimgel

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
PHP inside theme.php?
« on: August 25, 2006, 12:31:41 am »

Hey... My question is:

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

Code: [Select]
// 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:

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

then the output is:
Code: [Select]
<? include("test.php"); php ?>
why is it not possible to add php code inside the field?
« Last Edit: August 26, 2006, 12:04:33 pm by Nibbler »
Logged

Nibbler

  • Guest
Re: PHP inside theme.php?
« Reply #1 on: August 25, 2006, 12:32:35 am »

Because it's not valid PHP.
Logged

gelaskimgel

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: PHP inside theme.php?
« Reply #2 on: August 25, 2006, 01:18:34 am »

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?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: PHP inside theme.php?
« Reply #3 on: August 25, 2006, 05:34:41 am »

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.
Logged

gelaskimgel

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: PHP inside theme.php?
« Reply #4 on: August 25, 2006, 12:28:04 pm »

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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: PHP inside theme.php?
« Reply #5 on: August 25, 2006, 06:12:32 pm »

...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.
Logged

gelaskimgel

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: PHP inside theme.php?
« Reply #6 on: August 25, 2006, 06:36:43 pm »

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

Code: [Select]
<?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...
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: PHP inside theme.php?
« Reply #7 on: August 25, 2006, 07:14:17 pm »

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:
post 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.
Logged

gelaskimgel

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: PHP inside theme.php?
« Reply #8 on: August 25, 2006, 08:38:07 pm »

my existing file "test.php" is here: http://www.rdc.lir.dk/themes/neweb/test.php
Logged

gelaskimgel

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: PHP inside theme.php?
« Reply #9 on: August 25, 2006, 08:43:30 pm »

I don't understand what you mean with
Code: [Select]
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?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: PHP inside theme.php?
« Reply #10 on: August 25, 2006, 10:44:02 pm »

I don't understand what you mean with
Code: [Select]
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
Quote
themes/neweb/test.php
into "Path to custom footer include" (as suggested in one of my previous postings
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.
Logged

gelaskimgel

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: PHP inside theme.php?
« Reply #11 on: August 25, 2006, 11:47:45 pm »

ok GauGau... but I still does not understand what you mean with this:
Code: [Select]
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:
Code: [Select]
themes/neweb/test.php and in which line of that file?
Logged

gelaskimgel

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: PHP inside theme.php?
« Reply #12 on: August 26, 2006, 12:17:31 am »

ok GauGau I did understand you now :)
Logged

gelaskimgel

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: PHP inside theme.php?
« Reply #13 on: August 26, 2006, 11:35:01 am »

GauGau you can close the question... everything is working now :)
Logged
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 19 queries.