Jump to content

Variables in tpl files


Guest The Squirrel

Recommended Posts

Guest The Squirrel

I'm no PHP whizz and I've never used xtemplates before but I understand how to assign and display the value of a variable by doing something like this:

$view_cat->assign("MY_VAR", "Some stuff");

But there's something I don't understand.

I'm trying to add some content to view_cat.tpl. When I add {MY_VAR} anwhere below <!-- BEGIN: cat_desc --> it doesn't display.

How do I get my vars to work below that line?

Any advice or guidance appreciated!

Thanks!

James

Link to comment
Share on other sites

If you've got {MY_VAR} inside of the <!-- BEGIN: cat_desc --> block then I think you need:

$view_cat->assign("MY_VAR", 'stuffage');

$view_cat->parse("view_cat.cat_desc");

It won't work if you do

$view_cat->assign("MY_VAR", 'stuffage');

$view_cat->parse("view_cat");

The dots in ->parse indicating going into blocks of <!-- BEGIN: ..> <!-- END: ..>

I think ;)

Link to comment
Share on other sites

Guest The Squirrel

Thanks for the reply James!

Unfortunately that didn't quite work because I was trying to assign a variable to a sub-block after it had already been parsed.

Thanks a bundle for taking the time though.

James

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...