PHP in templates

Download plugins, language packs and stuff.

PHP in templates

Postby FI-DD » Thu Oct 12, 2006 2:09 pm

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.
Attachments
php-in-templates.zip
PHP in templates
(495 Bytes) Downloaded 819 times
Last edited by FI-DD on Thu Oct 19, 2006 6:52 pm, edited 1 time in total.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Ramon » Thu Oct 19, 2006 1:18 pm

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 "&raquo?PHP (member_name) ?&raquo".



Also when i want to post a html / xml example, cutenews sees it as real code instead of text.
Image
Ramon
 
Posts: 599
Joined: Wed Oct 12, 2005 8:51 pm
Location: Hoogeveen, NL

Postby scottdallas » Thu Oct 19, 2006 2:19 pm

$member_name! I like that. What else don't I know about?
Everyday I'm tumblin http://scodal.tumblr.com
User avatar
scottdallas
 
Posts: 2209
Joined: Thu May 04, 2006 6:46 pm
Location: US

Postby Ramon » Thu Oct 19, 2006 3:59 pm

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 ^^^
Image
Ramon
 
Posts: 599
Joined: Wed Oct 12, 2005 8:51 pm
Location: Hoogeveen, NL

Postby FI-DD » Thu Oct 19, 2006 6:50 pm

Ramon wrote: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 "&raquo?PHP (member_name) ?&raquo".


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.



Ramon wrote: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.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Ramon » Sat Oct 21, 2006 3:36 pm

But what if i want to post a HTML example?
Image
Ramon
 
Posts: 599
Joined: Wed Oct 12, 2005 8:51 pm
Location: Hoogeveen, NL

Postby Saszoo » Wed Oct 25, 2006 10:03 pm

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?

Code: Select all
< instead of <


Code: Select all
> instead of >




edit2: Goddammit!

eh... &-#-6-0-; equals <

&-#-6-0-; equals >
User avatar
Saszoo
 
Posts: 414
Joined: Wed Jun 07, 2006 10:34 pm
Location: Norway

Postby FI-DD » Thu Oct 26, 2006 9:53 am

User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby alien13 » Mon Apr 16, 2007 2:48 pm

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;

alien13
 
Posts: 20
Joined: Fri Apr 13, 2007 5:48 pm

Postby astrostart » Mon Apr 16, 2007 3:11 pm

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!
User avatar
astrostart
 
Posts: 124
Joined: Sun Feb 11, 2007 6:08 pm
Location: The Netherlands

Postby alien13 » Mon Apr 16, 2007 4:52 pm

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?
alien13
 
Posts: 20
Joined: Fri Apr 13, 2007 5:48 pm

Postby alien13 » Mon Apr 16, 2007 7:03 pm

I try everything, please someone help :(
alien13
 
Posts: 20
Joined: Fri Apr 13, 2007 5:48 pm

Postby FI-DD » Mon Apr 16, 2007 8:20 pm

Works fine for me. :?



What about this:

Code: Select all
<?php include ("http://mysite.com/wallpapers/index.php"); ?>
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby alien13 » Mon Apr 16, 2007 8:31 pm

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?
alien13
 
Posts: 20
Joined: Fri Apr 13, 2007 5:48 pm

Postby afxback » Tue May 22, 2007 5:20 pm

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.
afxback
 
Posts: 134
Joined: Fri Nov 11, 2005 4:59 pm

Next

Return to Additional Downloads



Who is online

Users browsing this forum: No registered users and 0 guests

cron