Jump to content

Parse Smarty Tags ..


ChrisColeman

Recommended Posts

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,

 

Link to comment
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) ?

 

 

 

 

 

 

 

 

 

 

     "

 

Link to comment
Share on other sites

  • 8 months later...

Hi bsmither,

Quote

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.

Do you mean that smarty made life harder for developers and limits the customization options?

My impression is that the smarty template engine makes the templates more readable, but limits the understanding of the underlying logic and possibly only give access to compiled templates. But as I'm new to smarty, I would like to hear about some developers/gurus for Cubecart to be sure that I'm not misunderstanding the pro and cons that smarty involves for cubecart.

Link to comment
Share on other sites

Smarty makes projects much easier and way more versatile.

It is important to keep in mind that Smarty gives methods to solve presentation logic, such as: if this, then show that and loop through this array.

Know that Smarty allows for procedural logic, such as: sort the array on this field and constructing a pagination sequence. There are valid reasons for being allowed to do this, but keeping display logic and procedure logic separate is best.

The limitations on customization and making things a bit harder of developers is as I hinted at: There is only the data that CubeCart has assigned to Smarty up to the point of rendering the template.

In my opinion, this is a simple flaw in the overall design of CubeCart, having a huge impact -- the solution being to throw all the processed data into the Smarty TemplateVar bucket, and only then start to compile/render the templates. This allows for skins to show any data anywhere.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...