简体   繁体   中英

Smarty Zend variable source

Is there a way to trace in which controller function the Smarty variables are assigned in Zend framework?

Example below:

{$TITLE}

This is in search.tpl

This must have been assigned using Smarty's assign function.

How can I locate that assignment?

Since the assign (documentation here ) function takes only 2 parameters, which are the key and the value (or a single parameter of key / value pairs) you probably won't be able to find programmatically what is the source of the assignation.

A Smarty template can also assign a value, using {assign} (documentation here ).

What you can do though, is a Find in Files (depending on your IDE, all decent ones like Sublime Text 2, Visual Studio, Notepad++, etc... offer you a way to look for a string in all the files in a folder, often giving you more options like filtering on the extension of the file) for the string ->assign("Title" or simply the literal "title" if you believe a template could have assigned it. From there, you will be able to find which source files assign this value. If there are multiple places where it's set and you want to debug which one gets executed, I'd suggest using some echo calls, they will appear in your HTML document right before your Template .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM