coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: attempt on July 28, 2007, 06:41:28 PM

Title: Insert php in theme.php
Post by: attempt on July 28, 2007, 06:41:28 PM
How can i insert php in theme.php? If i insert something like:
<?php
echo "test";
?>

it's not displayed, but if i look into the source of the page, it is there like above.
Title: Re: Insert php in theme.php
Post by: Nibbler on July 28, 2007, 06:55:53 PM
Leave out the php tags. For more details post what you are trying to accomplish.
Title: Re: Insert php in theme.php
Post by: attempt on July 28, 2007, 07:02:59 PM
If so, it displays as text
echo "test";

I want to insert an rssfeed using rss2html. It works on other page with php or html extension, but not working in coppermine.
Title: Re: Insert php in theme.php
Post by: attempt on July 28, 2007, 07:08:31 PM
I observed that it depends where I insert the code. I want to be inserted in
"// HTML template for the image rating box" section, but if I put the php code after EOT of this section it is displayed but not where I want to.
Title: Re: Insert php in theme.php
Post by: phill104 on July 28, 2007, 10:21:17 PM
I've used rss2html with coppermine a long time ago. IRC I inserted the code into template.html.

I was displaying an image generated by rss2html so just had to include an img src tag but it's quite simple to add any element of the feed to template.html
Title: Re: Insert php in theme.php
Post by: Nibbler on July 28, 2007, 11:11:45 PM
You can't use php in template.html. You can add php into your theme.php but you need to know how to write valid php. The way you are trying to do it is not valid. Post the exact code you need to insert.
Title: Re: Insert php in theme.php
Post by: phill104 on July 28, 2007, 11:51:26 PM
Nibbler,

With rss2html you don't really need php, that was my point. It generates a page from it's own script and you just display elements of that.  In my case it generated a weather graphic depending on location and that graphic was just displayed within template.html.

Hope this makes my reasoning clearer. I'm not too good at explaining things sometimes.
Title: Re: Insert php in theme.php
Post by: phill104 on July 28, 2007, 11:59:16 PM
Sorry to add another post.

Here is a better explanation of how it works.

http://www.feedforall.com/php-documentation.htm (http://www.feedforall.com/php-documentation.htm)
Title: Re: Insert php in theme.php
Post by: attempt on July 29, 2007, 07:44:55 PM
If anyone will be able to help me with the test code, I'll manage with any other php code.
Title: Re: Insert php in theme.php
Post by: Joachim Müller on July 30, 2007, 07:40:38 AM
Do as Nibbler suggested:
Quote from: Nibbler on July 28, 2007, 06:55:53 PM
For more details post what you are trying to accomplish.
Title: Re: Insert php in theme.php
Post by: attempt on July 30, 2007, 10:44:43 AM
// HTML template for the image rating box
$template_image_rating = <<<EOT

       <tr>
                <td>
<div align="justify" class="graybox postmetadata">
<h3 style="margin: 0 0 0;"><span style="float:left">{TITLE}</span></h3>
      <p><span style="float:right">{VOTES}</span></p>
      <p><br />
      </p>
      <table width="100%"><tr>
                <td width="" align="center"><a href="{RATE0}" title="{RUBBISH}"><img src="themes/oranje/images/rating0.gif" alt="{RUBBISH}" border="0" /><br /></a></td>
                <td width="" align="center"><a href="{RATE1}" title="{POOR}"><img src="themes/oranje/images/rating1.gif" alt="{POOR}" border="0" /><br /></a></td>
                <td width="" align="center"><a href="{RATE2}" title="{FAIR}"><img src="themes/oranje/images/rating2.gif" alt="{FAIR}" border="0" /><br /></a></td>
                <td width="" align="center"><a href="{RATE3}" title="{GOOD}"><img src="themes/oranje/images/rating3.gif" alt="{GOOD}" border="0" /><br /></a></td>
                <td width="" align="center"><a href="{RATE4}" title="{EXCELLENT}"><img src="themes/oranje/images/rating4.gif" alt="{EXCELLENT}" border="0" /><br /></a></td>
                <td width="" align="center"><a href="{RATE5}" title="{GREAT}"><img src="themes/oranje/images/rating5.gif" alt="{GREAT}" border="0" /><br /></a></td>
        </tr></table>
</div>
<center>
$XMLFILE = "http://stiri.myweb.ro/e107_plugins/rss_menu/rss.php?1.1";
$TEMPLATE = "http://www.myweb.com/templaterss.html";
$MAXITEMS = "4";
include("rss2html.php");
</center>
</td>
</tr>
EOT;


the section between center tag is my code. It could be very well: echo "please show";
Title: Re: Insert php in theme.php
Post by: Nibbler on July 30, 2007, 12:00:22 PM

$XMLFILE = "http://stiri.myweb.ro/e107_plugins/rss_menu/rss.php?1.1";
$TEMPLATE = "http://www.myweb.com/templaterss.html";
$MAXITEMS = "4";

ob_start();
include("rss2html.php");
$rss = ob_get_clean();

// HTML template for the image rating box
$template_image_rating = <<<EOT

       <tr>
                <td>
<div align="justify" class="graybox postmetadata">
<h3 style="margin: 0 0 0;"><span style="float:left">{TITLE}</span></h3>
      <p><span style="float:right">{VOTES}</span></p>
      <p><br />
      </p>
      <table width="100%"><tr>
                <td width="" align="center"><a href="{RATE0}" title="{RUBBISH}"><img src="themes/oranje/images/rating0.gif" alt="{RUBBISH}" border="0" /><br /></a></td>
                <td width="" align="center"><a href="{RATE1}" title="{POOR}"><img src="themes/oranje/images/rating1.gif" alt="{POOR}" border="0" /><br /></a></td>
                <td width="" align="center"><a href="{RATE2}" title="{FAIR}"><img src="themes/oranje/images/rating2.gif" alt="{FAIR}" border="0" /><br /></a></td>
                <td width="" align="center"><a href="{RATE3}" title="{GOOD}"><img src="themes/oranje/images/rating3.gif" alt="{GOOD}" border="0" /><br /></a></td>
                <td width="" align="center"><a href="{RATE4}" title="{EXCELLENT}"><img src="themes/oranje/images/rating4.gif" alt="{EXCELLENT}" border="0" /><br /></a></td>
                <td width="" align="center"><a href="{RATE5}" title="{GREAT}"><img src="themes/oranje/images/rating5.gif" alt="{GREAT}" border="0" /><br /></a></td>
        </tr></table>
</div>
<center>
$rss
</center>
</td>
</tr>
EOT;
Title: Re: Insert php in theme.php
Post by: attempt on July 30, 2007, 03:12:06 PM
thank you