For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > August 2005 > Embedding an object method call in double quotes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Embedding an object method call in double quotes
Dave Dribin

2005-08-20, 7:00 pm

I'm not sure if this is possible, but I'm trying to embed an object
method call in double quotes, for example:

{include file="header.tpl" title="View for $item->name()"}

But, this isn't working, as I get:

<title>View for Object->name()</title>

If I try to use the backticks to quote the method call, as mentioned in
this page:

http://smarty.php.net/manual/en/lan...ntax.quotes.php

like this:

{include file="header.tpl" title="View for `$item->name()`"}

I get this:

<title>View for `Object->name()`</title>

The only way I can get it to work is to assign the name to a variable
without using double quotes:

{assign var="name" value=$item->name()}
{include file="header.tpl" title="View for $name"}

Is this a bug? The documentation doesn't show a method call example,
but it does say to use backticks to quote object reference. Or do I
have the syntax wrong? I'm using Smarty version 2.6.10.

Thanks!

-Dave
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com