Jump to content
Sign in to follow this  
ChrisColeman

Parse Smarty Tags ..

Recommended Posts

Hi,

        There is an option when editing a site document to have smarty tags parsed, which would be quite useful but I cannot make it work.

Where should I assign the smarty variables to be included in the documents ?

Many Thanks, Chris.

Share this post


Link to post
Share on other sites

As much as this was a welcome new feature (several versions ago), it is, standing alone, somewhat limited. There is only the data that CubeCart has assigned to Smarty up to the point of rendering the document's contents. To get a sense of what data is available, edit the skin template content.document.php as follows:

At the bottom of the file, add:

{debug}

Have CubeCart clear its internal cache.

When a document is to be shown, the browser will want to show a popup. Let it. The popup is a list of all the variables available and their values when CubeCart tells Smarty to assign the document contents to the variable DOCUMENT.

So, one would need to create a plugin or Code Snippet to add whatever actual custom values that are to replace the custom Smarty placeholders in the document content.

Smarty is able to obtain a small amount of additional data - such as the time and date - from PHP directly. For example:

In the document's contents:

Good {if $smarty.now|date_format:'%R' lt 12}Morning{elseif $smarty.now|date_format:'%R' lt 18}Afternoon{else}Evening{/if} {if $IS_USER}Valued{else}Future{/if} Customer,

 

Edited by bsmither

Share this post


Link to post
Share on other sites

OK,

     the only way I could make this work is by inventing a new hook ..

When the document is fetched by Smarty  (At end of function getDocument in cubecart.class .

                   ie.        $contents['doc_content'] = ($contents['doc_parse']==1) ? $GLOBALS['smarty']->fetch('string:'.$contents['doc_content']) : $contents['doc_content'];     

there are no global smarty variables available to assign to the RAW document,  therefore the SMARTY tags in the document are replaced with nothing.

SO just before that I have included,

    foreach ($GLOBALS['hooks']->load('class.cubecart.document_source_parse') as $hook) include $hook;

Which enables me to use smarty tags in documents (Store Name, Website URL, Address, Whatever).

It would be nice if you guys (or girls) could make this hook permanent I guess it could be useful ?

Regards Chris.

 

ps. Am i wrong or did CubeCart once have this feature (cc2 || cc3) ?

 

 

 

 

 

 

 

 

 

 

     "

 

Edited by ChrisColeman

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×