Back to the Smarty code now??”inside the HTML code that forms the layout of the Smarty template (presentation/
templates/departments_list.tpl), you can see the Smarty tags that do the magic:
{* Loop through the list of departments *}
{section name=i loop=$obj->mDepartments}
{assign var=selected value=""}
{* Verify if the department is selected to decide what CSS style
to use *}
{if ($obj->mSelectedDepartment == $obj->mDepartments[i].department_id)}
{assign var=selected value="class=\"selected\""}
{/if}
{* Generate a link for a new department in the list *}
{$obj->mDepartments[i].name}
{/section}
Smarty template sections are used for looping over arrays of data. In this case, you want to loop over the departments
array kept in $obj->mDepartments:
{section name=i loop=$obj->mDepartments}
...
{/section}
Inside the loop, you verify whether the current department in the loop ($obj->mDepartments[i].department_id)
has the ID that was mentioned in the query string ($obj->mSelectedDepartment). Depending on this, you
decide what style to apply to the name by saving the style name (selected or default style) to a variable named
selected.
This variable is then used to generate the link:
{$obj->mDepartments[i].
Pages:
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192