PHP in templates

Download plugins, language packs and stuff.

Postby jackavin » Wed Apr 08, 2009 5:06 pm

i mean in template like full-story but i want it in comment section
jackavin
 
Posts: 53
Joined: Wed Oct 01, 2008 7:21 pm

Postby Hawk » Thu Apr 09, 2009 10:28 am

I guess you could use the Quick Tags tool from Options in administration panel & make something like that.
User avatar
Hawk
 
Posts: 279
Joined: Tue Aug 29, 2006 9:00 pm

Postby FI-DD » Fri Apr 17, 2009 1:35 pm

Just adding this:
Code: Select all
add_filter('news-comment', 'php_in_template');


below this:
Code: Select all
add_filter('news-entry', 'php_in_template');


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

Postby jackavin » Sun Apr 19, 2009 3:06 pm

thank you it's working but one thing

when i user include("file"); the tag {comment} at include("file") can't be view.

but the in full news it does why that.


thank you FI-DD u awsome
jackavin
 
Posts: 53
Joined: Wed Oct 01, 2008 7:21 pm

Postby alex » Thu Apr 30, 2009 6:48 pm

After I save the template all the $ dissapears, the same happens with /$.What can I do?
alex
 
Posts: 24
Joined: Thu Aug 21, 2008 5:05 pm

Postby FI-DD » Tue May 12, 2009 3:25 pm

alex wrote:the same happens with /$.

Use \$ instead of /$.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby alex » Sat May 16, 2009 6:01 pm

now is working, but when I use the following script it return this error: Parse error: syntax error, unexpected '"' in /home/domain/nw/plugins/php-in-templates.php(28) : eval()'d code on line 27
Code: Select all
<?php

//...get direct FLV link for Dailymotion


//http://www.dailymotion.com/us/featured/channel/sport/video/x8kqo2_bsides-salto-base-nocturno-en-ensan_sport
//http://keepvid.com/?url=http://www.dailymotion.com/us/featured/channel/sport/video/x8kqo2_bsides-salto-base-nocturno-en-ensan_sport
//http://vid.akm.dailymotion.com/18/512x384/h264/14404610.h264?aksessionid=1236484818170_912376&akauth=1236657618_89762dcab95c2ecae031f3b333df7437


//\$geturl = \$video_detail->video_url; // retrieve video_url from the database
//\$geturl = "http://keepvid.com/?url=" . \$video_detail->video_url;
\$geturl = "http://keepvid.com/?url=http://www.dailymotion.com/video/x5cayu_walking-contradiction-green-day_music";


if(function_exists('curl_init'))
{
  \$ch      = curl_init();
  \$timeout = 30; // set to zero for no timeout
  curl_setopt(\$ch, CURLOPT_URL, \$geturl);
  curl_setopt(\$ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt(\$ch, CURLOPT_CONNECTTIMEOUT,\$timeout);
  \$file_contents = curl_exec(\$ch);
  curl_close(\$ch);
}

\$start_position = strpos(\$file_contents, "Links found on");
\$start_position = strpos(\$file_contents, "Report any problems to", \$start_position);
\$start_position = strpos(\$file_contents, "<a href=\"", \$start_position) + 9;
\$end_position   = strpos(\$file_contents, "\"", \$start_position) - \$start_position;
\$getflvlink     = substr(\$file_contents, \$start_position, \$end_position);
\$flv_link       = trim(\$getflvlink);

//\$flv_link = "http://proxy-35.dailymotion.com/16/320x240/flv/7746594.flv?3729391860564098ca7ed38576d57c4e13a7dae";
//\$flv_link = "http://vid.akm.dailymotion.com/18/512x384/h264/14404610.h264?aksessionid=1236484818170_912376&akauth=1236657618_89762dcab95c2ecae031f3b333df7437";

?>

<html>

  <head>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>

    <script type="text/javascript">
      var flashvars =
      {
        'file':                      encodeURIComponent('<?php echo \$flv_link; ?>'),
        'type':                     'video',
        'skin':                     'nacht',
        'controlbar':               'bottom',
        'stretching':               'fill',
        'frontcolor':               'FFFFFF',
        'lightcolor':               'FF6600',
        'autostart':                'true'
      };

      var params =
      {
        'allowfullscreen':          'true',
        'allowscriptaccess':        'always'
      };

      var attributes =
      {
        'name':                     'JomPlayerId1',
        'id':                       'JomPlayerId1'
      };

      swfobject.embedSWF('player.swf', 'JomTubePlayerId1', '430', '300', '9.0.124', false, flashvars, params, attributes);
    </script>

  </head>

  </body>

    <div id="JomPlayerContainer" class="JomPlayerContainer"><a id="JomTubePlayerId1" class="player1" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Adobe Flash Player to see this video.</a></div>

  </body>

</html>


if I include a page containing this script is working but if I use it in the template it return the error
alex
 
Posts: 24
Joined: Thu Aug 21, 2008 5:05 pm

Postby MiNi.SpIdEr » Sun May 17, 2009 7:06 am

hiii

i activeed the plug but .... nothing happen !!! i try the eg. also nothing

Code: Select all
tags: <?php echo 'blahblah'; ?>


actually i want put that
Code: Select all
<?=cn_meta('keywords'); ?>
but nothing also
Code: Select all
<?PHP=cn_meta('keywords'); ?>


any idea ??? coz the topic came too long with out on solve :(


:roll:
MiNi.SpIdEr
 
Posts: 78
Joined: Tue Jan 22, 2008 6:30 pm

Postby GoldenGonaz » Fri Jul 10, 2009 12:50 pm

Hey guys, I am having a problem making things like {avatar} appear within <?php (there is more code to this, I have chopped most of it out to show simply what I mean.

<?php
$background="http://www.website.com/{avatar}.png";
?>

This doesn't seem to work? It doesn't replace {avatar} with what it should... I'm not really any good with php, so I'll try and explain what I think is happening as best and unfortunately incorrectly php wise as I can.

I think <?php is sort of executing before it can display the {avatar} part to cutenews. So cutenews doesn't see the {avatar} so can't replace it with what it would do it if weren't within <?php

Any help you can be would be very much appreciated :D If my ""theory"" is right, is it possible to fix this? Or is it something totally different that's wrong!

Thanks
GoldenGonaz
 
Posts: 32
Joined: Wed Oct 04, 2006 1:00 pm

Postby riri » Wed Oct 28, 2009 7:28 am

hello,

I'd like to know what it is for this plugin and how to operate?

thank you in advance
riri
 
Posts: 51
Joined: Tue Aug 21, 2007 8:32 pm

Postby DarkSlim » Thu Oct 29, 2009 2:51 pm

For "GoldenGonaz":

As the first post says you need to 'escape the variables', so it should look like:

Code: Select all
<?php
\$background="http://www.website.com/{avatar}.png";
?>


And for riri:

This plugin enables you to use php code in the templates of your CuteNewsRU
and not only regular html, this is usefull for includes (include another file) for example

To install download the Zip file from first post and put it in the plugins folder. :)

Edit: Btw, you pretty much have to do this for it work:

Open: inc/show.news.php

Find:

Code: Select all
$output = preg_replace('/\[full-link\](.*?)\[\/full-link\]/is', '', $output);


After add:

Code: Select all
$output = preg_replace_callback('/<\\?php(.*?)\\?>/is', 'phpTemplateEval', $output);
User avatar
DarkSlim
 
Posts: 298
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL

Postby riri » Thu Oct 29, 2009 3:41 pm

I understand thank you for the explanation:)
riri
 
Posts: 51
Joined: Tue Aug 21, 2007 8:32 pm

Postby GoldenGonaz » Thu Jul 08, 2010 6:15 pm

DarkSlim wrote:For "GoldenGonaz":

As the first post says you need to 'escape the variables', so it should look like:

Code: Select all
<?php
\$background="http://www.website.com/{avatar}.png";
?>



I have escaped all the variables, but when I do this is causes many errors in the php file I am including... is there a fix for this?


I receive this error: Warning: Unexpected character in input: '\' (ASCII=92) state=1
GoldenGonaz
 
Posts: 32
Joined: Wed Oct 04, 2006 1:00 pm

Re: PHP in templates

Postby eberswine » Sun Dec 12, 2010 6:50 am

I am stuck with getting this to work..

I have tried almost everything that this post suggested. I got really close when I included the variables in the show.news.php page... but still no cigar.

Basically, I have found this really nice php photogallery script. It is set up to upload photos and create great "galleries". The best thing about it, is there is just 2 lines of code to include for your gallery.

Code: Select all
<?php
$cat="1";
include("/path/to/photogallery/mainpage.php"); 
?>


Where $cat is the category of the photogallery you make. And the include code is the meat and potatoes of the script that handles all the includes and settings of you galleries.

So, what I was thinking, is having this script installed and then if I have a News Post with a lot of photos I would like to show off, I would just make a new category (inside the photo script not CNR) and then get the $cat number (which is just the id of the photogallery) and then I would either just include it inside the full story like above... or maybe we could make shortcodes for it... ??? Or use if cutefields statement and then just include the gallery number in a cutefield text field when posting..

I have tried almost all of the above with the exception of creating the shortcodes.. (not sure how)..

And, yes, I have tried escaping the variable too.

The problem is that it won't recognize any Other variables outside of CNR (that is why I was trying to make short codes in the show.news.php page)

It is strange that it won't even echo a simple variable like $cat = '2' .. I have tried to include a variable on one of my pages with $cat = '2'; and then I would try an echo $cat; in my template and or full story, but it came up blank... That is when I started to play around with the show.news.php page and try to include my variables in there.. and I am getting close.. but I need some professional help.

Thanks in advance. This will be a great feature if we can get it working!!
User avatar
eberswine
 
Posts: 289
Joined: Thu Apr 26, 2007 7:23 pm

Re: PHP in templates

Postby Hawk » Mon Dec 13, 2010 9:01 am

Could you post a link to the photogallery script so I could check the code?
User avatar
Hawk
 
Posts: 279
Joined: Tue Aug 29, 2006 9:00 pm

PreviousNext

Return to Additional Downloads



Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron