Insert php in theme.php Insert php in theme.php
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Insert php in theme.php

Started by attempt, July 28, 2007, 06:41:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

attempt

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.

Nibbler

Leave out the php tags. For more details post what you are trying to accomplish.

attempt

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.

attempt

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.

phill104

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
It is a mistake to think you can solve any major problems just with potatoes.

Nibbler

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.

phill104

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.
It is a mistake to think you can solve any major problems just with potatoes.

phill104

Sorry to add another post.

Here is a better explanation of how it works.

http://www.feedforall.com/php-documentation.htm
It is a mistake to think you can solve any major problems just with potatoes.

attempt

If anyone will be able to help me with the test code, I'll manage with any other php code.

Joachim Müller

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.

attempt

// 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";

Nibbler


$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;

attempt