| Author |
Message |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2736 Location: Germany |
|
PHP in templates |
|
This plugin allows you to use PHP in the templates.
Make sure you use the full PHP tags: <?php echo 'blahblah'; ?>
This won't work: <? echo 'blahblah'; ?>
And you have to escape the variables: Use \$variable instead of $variable.
| Description: |
|
 Download |
| Filename: |
php-in-templates.zip |
| Filesize: |
495 Bytes |
| Downloaded: |
504 Time(s) |
Last edited by FI-DD on Thu Oct 19, 2006 6:52 pm; edited 1 time in total |
|
| Thu Oct 12, 2006 2:09 pm |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
Ramon
Joined: 12 Oct 2005 Posts: 462 Location: Hoogeveen, NL |
|
|
|
This mod doesn't work the way it is supposted to..
When I just use $member_name or something without the <?PHP and ?> it works. When I use the <?PHP and ?> it show up something like this "»?PHP (member_name) ?»".
Also when i want to post a html / xml example, cutenews sees it as real code instead of text.
_________________
 |
|
| Thu Oct 19, 2006 1:18 pm |
|
 |
scottdallas

Joined: 04 May 2006 Posts: 1843 Location: US |
|
|
|
$member_name! I like that. What else don't I know about?
_________________ www.scottdizzle.com uses cnr
last update: 07-22-08: 8:30 pm |
|
| Thu Oct 19, 2006 2:19 pm |
|
 |
Ramon
Joined: 12 Oct 2005 Posts: 462 Location: Hoogeveen, NL |
|
|
|
Neh thats a global of SDK. SDK is a IPB integration tool.
I do not have a name field if people want to comment, they only have to type in their comment and the $member_name get's there name from the database when logged in. So al my forum members can also post on the website with their forum account and in that way members don't have to also sign up for a cutenews.ru account.
^^^ Crappy English, sorry about that, bit tired ^^^
_________________
 |
|
| Thu Oct 19, 2006 3:59 pm |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2736 Location: Germany |
|
|
|
 |  | This mod doesn't work the way it is supposted to..
When I just use $member_name or something without the <?PHP and ?> it works. When I use the <?PHP and ?> it show up something like this "»?PHP (member_name) ?»". |
Well, I tested it again. It's working for me. Only problem is that PHP is enabled in short and full story too.
And I just found out that you have to escape variables. So use \$variable instead of $variable.
 |  | Also when i want to post a html / xml example, cutenews sees it as real code instead of text. |
That's normal, isn't it? Otherwise a story with an image would show <img src="image" /> instead of the image.
|
|
| Thu Oct 19, 2006 6:50 pm |
|
 |
Ramon
Joined: 12 Oct 2005 Posts: 462 Location: Hoogeveen, NL |
|
|
|
But what if i want to post a HTML example?
_________________
 |
|
| Sat Oct 21, 2006 3:36 pm |
|
 |
Saszoo

Joined: 07 Jun 2006 Posts: 409 Location: Norway |
|
|
|
I think you have to go the hard way and type
< for the < symbol
and
> for the > symbol
then it wont be recognized as code...
well, might be doable with some php and str_replace of sorts when <span class="code"> or something...
edit:
Hey! this forum translated my ASCII code to html-code!
hm does this work?
 |  | < instead of < |
 |  | > instead of > |
edit2: Goddammit!
eh... &-#-6-0-; equals <
&-#-6-0-; equals >
_________________ My cute.ru site |
|
| Wed Oct 25, 2006 10:03 pm |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2736 Location: Germany |
|
|
| Thu Oct 26, 2006 9:53 am |
|
 |
alien13
Joined: 13 Apr 2007 Posts: 17
|
|
|
|
This mod doesn't work for me. I try to write <?php include 'http://mysite.com/wallpapers/index.php'; ?> nithing happens. Here is part of my template where i use php.
 |  |
$template_full = <<<HTML
[page-link]({pages})[/page-link]
[if-logged]<small style="font-size: 10px;"> (<a href="{cutepath}/index.php?mod=editnews&id={id}" target="_blank" title="Edit news">Edit</a> / <a href="{cutepath}/index.php?mod=editnews&action=delete&selected_news[]={id}" target="_blank" title="Delete news">Delete</a>)</small>[/if-logged]
<table width="730" height="25" border="0" cellspacing="0" cellpadding="0" align="center" class="article_top">
<tr>
<td width="32"></td>
<td width="468" align="justify">{title}</td>
<td width="230" align="right">Date: {date}</td>
</tr>
</table>
<table width="730" border="0" cellspacing="0" cellpadding="0" align="center" class="cell4">
<tr>
<td width="100%" align="justify" class="cell6">{full-story}</td></td>
</tr>
</table>
<?php include 'http://mysite.com/wallpapers/index.php'; ?>
<a name="comments"></a>
HTML;
|
|
|
| Mon Apr 16, 2007 2:48 pm |
|
 |
astrostart

Joined: 11 Feb 2007 Posts: 124 Location: The Netherlands |
|
|
|
Are there variables on the includepage?
If so: follow FI-DD's advice in the startpost of the topic.
_________________ My site: http://www.astrostart.nl | Thanks to everyone here who has helped me! |
|
| Mon Apr 16, 2007 3:11 pm |
|
 |
alien13
Joined: 13 Apr 2007 Posts: 17
|
|
|
|
It has variables, but even when I try to include another page only with simple text in the file, it didn't want to show anything. I don't know where is the problem. I download the plugin from the first post, upload him to the plugins dir and then from the admin-plugins I activate it. Do I need to make some other changes?
|
|
| Mon Apr 16, 2007 4:52 pm |
|
 |
alien13
Joined: 13 Apr 2007 Posts: 17
|
|
|
|
I try everything, please someone help 
|
|
| Mon Apr 16, 2007 7:03 pm |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2736 Location: Germany |
|
|
|
Works fine for me.
What about this:
 |  | <?php include ("http://mysite.com/wallpapers/index.php"); ?> |
|
|
| Mon Apr 16, 2007 8:20 pm |
|
 |
alien13
Joined: 13 Apr 2007 Posts: 17
|
|
|
|
Ok for now I solve the problem. When I try to use the plugin it did'n work, I don't know why. Then I try to copy in inc/show.news.php:
after:
$output = preg_replace('/\[full-link\](.*?)\[\/full-link\]/is', '', $output);
add
$output = preg_replace_callback('/<\\?php(.*?)\\?>/is', 'phpTemplateEval', $output);
and now work like a charm. Is this way is secure?
|
|
| Mon Apr 16, 2007 8:31 pm |
|
 |
afxback
Joined: 11 Nov 2005 Posts: 126
|
|
|
|
This plugin did not work for me. When I include:
<?php
include...
$variable...
?>
after saving the template, it removes"$" from php code and if escape it with"\" again no changes appear and "$" is removed.
|
|
| Tue May 22, 2007 5:20 pm |
|
 |
|