Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
PHP in templates
Goto page 1, 2, 3  Next
 
Reply to topic    Forum Index » Additional Downloads View previous topic
View next topic
PHP in templates
Author Message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post PHP in templates Reply with quote
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.



php-in-templates.zip
 Description:
PHP in templates

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 View user's profile Send private message
Guest








Please login to hide the ads.

Ramon



Joined: 12 Oct 2005
Posts: 462
Location: Hoogeveen, NL

Post Reply with quote
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.

_________________
Thu Oct 19, 2006 1:18 pm View user's profile Send private message Visit poster's website
scottdallas



Joined: 04 May 2006
Posts: 1843
Location: US

Post Reply with quote
$member_name! I like that. What else don't I know about?

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm
Thu Oct 19, 2006 2:19 pm View user's profile Send private message Visit poster's website AIM Address
Ramon



Joined: 12 Oct 2005
Posts: 462
Location: Hoogeveen, NL

Post Reply with quote
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 View user's profile Send private message Visit poster's website
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
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.
Thu Oct 19, 2006 6:50 pm View user's profile Send private message
Ramon



Joined: 12 Oct 2005
Posts: 462
Location: Hoogeveen, NL

Post Reply with quote
But what if i want to post a HTML example?

_________________
Sat Oct 21, 2006 3:36 pm View user's profile Send private message Visit poster's website
Saszoo



Joined: 07 Jun 2006
Posts: 409
Location: Norway

Post Reply with quote
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:
< instead of <


Code:
> instead of >




edit2: Goddammit!

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

&-#-6-0-; equals >

_________________
My cute.ru site
Wed Oct 25, 2006 10:03 pm View user's profile Send private message Visit poster's website
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
http://english.cutenews.ru/forum/posting-code-t547.html
Thu Oct 26, 2006 9:53 am View user's profile Send private message
alien13



Joined: 13 Apr 2007
Posts: 17

Post Reply with quote
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.



Quote:


$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 View user's profile Send private message
astrostart



Joined: 11 Feb 2007
Posts: 124
Location: The Netherlands

Post Reply with quote
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 View user's profile Send private message Visit poster's website
alien13



Joined: 13 Apr 2007
Posts: 17

Post Reply with quote
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 View user's profile Send private message
alien13



Joined: 13 Apr 2007
Posts: 17

Post Reply with quote
I try everything, please someone help Sad
Mon Apr 16, 2007 7:03 pm View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
Works fine for me. Confused



What about this:

Code:
<?php include ("http://mysite.com/wallpapers/index.php"); ?>

Mon Apr 16, 2007 8:20 pm View user's profile Send private message
alien13



Joined: 13 Apr 2007
Posts: 17

Post Reply with quote
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 View user's profile Send private message
afxback



Joined: 11 Nov 2005
Posts: 126

Post Reply with quote
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 View user's profile Send private message
Display posts from previous:    
Reply to topic    Forum Index » Additional Downloads All times are GMT + 1 Hour
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.