Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Help! add star rating to template file

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
shawdy
Smarty Rookie


Joined: 12 Nov 2010
Posts: 5

PostPosted: Fri Nov 12, 2010 12:07 pm    Post subject: Help! add star rating to template file Reply with quote

Hello i need help. I dont understand smarty newb! all i am trying to do is include 1 line in a template, but the line is simply printed on screen or gives loads of errors.

I do not know how to write a plugin, as i said im a newb to smarty, and not to good with php.

This is the line for a star rating script i need to show on my site.

{php} echo pullRating(35,false,false,false,NULL); {/php}

Please note using the {php} tags simply outputs the whole line on screen like text..


The file im trying to include this in shows images which i need rated, its a html file, not .tpl file.

The other lines in the file look like this

{*include file='front_header.html'*}

WHen i add the * to the line above like so

{*} echo pullRating(35,false,false,false,NULL); {/php*}


It just gives errors, could you please help me add this line to my page.. ?


Thankyou in advance.
Back to top
View user's profile Send private message
shawdy
Smarty Rookie


Joined: 12 Nov 2010
Posts: 5

PostPosted: Mon Nov 15, 2010 1:08 am    Post subject: Nice forum congratulations are in order Reply with quote

Nice forum congratulations are in order, must be the only forum ever i have submited a post and not recieved one reply of friendly help.

Well done and carry on the great community support.. fanatastic.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Nov 15, 2010 2:32 am    Post subject: Reply with quote

well your scarcasm doesn't help any, but maybe because nobody knows what you are asking, or has an answer for you?

to include a text (html) file use {fetch}. You probably should learn how to write plugin files, as it would be the proper solution over {php} tags. I'm still not 100% sure what you are asking anyways, is something not working that was working?

This:


{*include file='front_header.html'*}


is a comment in Smarty, it looks like someone commented out an include statement. Maybe reading the Smarty manual once through would answer a lot of your questions. It shows how to make plugins too. Much time was spent writing it, I'd recommend reading it.
Back to top
View user's profile Send private message Visit poster's website
shawdy
Smarty Rookie


Joined: 12 Nov 2010
Posts: 5

PostPosted: Mon Nov 15, 2010 2:43 am    Post subject: Reply with quote

apologise for the remarks,

All im trying to do is include this line so it outputs a star rating script,

ive used it before on a normal php site just like this

<?php echo pullRating(35,false,false,false,NULL); ?>


The script im trying to add this too uses smarty ( which ive never used before )

The script has files which have lines it like this

{*include file='front_header.html'*} etc.


when i add the line with the <? all it does is print the line on the screen

if i wrap the line {* and *} it just gives a page full of errors.

i really have no idea how to do this or write any plugin,
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Nov 15, 2010 3:04 am    Post subject: Reply with quote

{* *} are comments in Smarty. Normally tags look like

{include ....}

in the template. You might be able to use {include_php ...} to include your script directly.
Back to top
View user's profile Send private message Visit poster's website
SLX
Smarty Rookie


Joined: 19 Nov 2009
Posts: 11
Location: Wroclaw, Poland

PostPosted: Tue Nov 16, 2010 12:15 pm    Post subject: Reply with quote

You want to execute php code from within smarty template file.
{php} tag is by default disabled for security purposes. It can be enabled, but the correct approach is to writing in your .php file:
Code:
$smarty->assign('PullRating', pullRating(35,false,false,false,NULL));
and in template file just:
Code:
{PullRating}


The above variable "$smarty" can be named different in your scripts. Search proper name in other .php files. Somewhere it is assigned like this
Code:
$smarty = new smarty()
Back to top
View user's profile Send private message
shawdy
Smarty Rookie


Joined: 12 Nov 2010
Posts: 5

PostPosted: Tue Nov 16, 2010 12:19 pm    Post subject: Reply with quote

Thankyou for your help i`ll take a look at what you`ve said, see if this works,
Very Happy
Back to top
View user's profile Send private message
shawdy
Smarty Rookie


Joined: 12 Nov 2010
Posts: 5

PostPosted: Tue Nov 16, 2010 11:30 pm    Post subject: Reply with quote

didnt work for me . to give you an idea what the rest of the file looks like ill show below.


It seems what ever i add to the file will only print to screen like text. unless i add a * sign like the other lines, but then it just gives errors.

I wasn`t sure of the variable name as you mentioned so left the line as is, although i suspect it may be mmb ?


----------file begin------------------

{*include file='front_header.html'*}


>>>>> trying to add the line here to display the star rating <<<<<

Code:
{***** Forms/Items ************************************************************}
{*if $mmb_forms_comnt.filled*}
  {*if $mmb_config.module_comnt*}
  {*include file='api/section_forms_media.html' forms=$mmb_forms_comnt perm=$mmb_page.perm.comnt.edit_list perm1=$mmb_page.perm.comnt.admn_list copy=true*}
  {*include file='api/section_items.html' table=$mmb_table_comnt perm=$mmb_page.perm.comnt.view_list perm1=$mmb_page.perm.media.view_self title=$mmb_config.titles.sect.section_comments filters='comments' viewtype='table' class='root_blog'*}
  {*/if*}
  {*include file='api/section_items.html' table=$mmb_table_media perm=$mmb_page.perm.media.view_self perm1=true                           title=''                                       filters=false      viewtype='table' class=''*}
  {*include file='api/section_forms_media.html' forms=$mmb_forms_media perm=$mmb_page.perm.media.edit_self perm1=$mmb_page.perm.media.admn_self copy=false*}
{*elseif is_array($mmb_forms_media.errors) && count($mmb_forms_media.errors)*}
  {*include file='api/section_forms_media.html' forms=$mmb_forms_media perm=$mmb_page.perm.media.edit_self perm1=$mmb_page.perm.media.admn_self copy=false*}
  {*include file='api/section_items.html' table=$mmb_table_media perm=$mmb_page.perm.media.view_self perm1=true                           title=''                                       filters=false      viewtype='table' class=''*}
  {*if $mmb_config.module_comnt*}
  {*include file='api/section_items.html' table=$mmb_table_comnt perm=$mmb_page.perm.comnt.view_list perm1=$mmb_page.perm.media.view_self title=$mmb_config.titles.sect.section_comments filters='comments' viewtype='table' class='root_blog'*}
  {*include file='api/section_forms_media.html' forms=$mmb_forms_comnt perm=$mmb_page.perm.comnt.edit_list perm1=false copy=true*}
  {*/if*}
{*else*}
  {*include file='api/section_items.html' table=$mmb_table_media perm=$mmb_page.perm.media.view_self perm1=true                           title=''                                       filters=false      viewtype='table' class=''*}
  {*if $mmb_config.module_comnt*}
  {*include file='api/section_items.html' table=$mmb_table_comnt perm=$mmb_page.perm.comnt.view_list perm1=$mmb_page.perm.media.view_self title=$mmb_config.titles.sect.section_comments filters='comments' viewtype='table' class='root_blog'*}
  {*include file='api/section_forms_media.html' forms=$mmb_forms_comnt perm=$mmb_page.perm.comnt.edit_list perm1=false copy=true*}
  {*/if*}
  {*include file='api/section_forms_media.html' forms=$mmb_forms_media perm=$mmb_page.perm.media.edit_self perm1=$mmb_page.perm.media.admn_self copy=false *}
{*/if*}
{***** Forms/Items ************************************************************}


---------end-----------------
Back to top
View user's profile Send private message
SLX
Smarty Rookie


Joined: 19 Nov 2009
Posts: 11
Location: Wroclaw, Poland

PostPosted: Mon Nov 22, 2010 9:34 am    Post subject: Reply with quote

Maybe this is not a smarty. How do you known if it is? Can you post your index.php?
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
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


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP