SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smarty templates display

    I have 2 template files, department_list.tpl and category_list.tpl

    How can I have the categories for each department to display right under the department name, when clicked?

    Your help will be greatly appreciated.


    Code:
    {* departments_list.tpl *}
    {load_presentation_object filename="departments_list" assign="obj"}
    {* Start departments list *}
    <div class="box">
      <p class="box-title">Choose a Department</p>
      <ul>
      {* 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}
        <li>
          {* Generate a link for a new department in the list *}
          <a {$selected} href="{$obj->mDepartments[i].link_to_department}">
            {$obj->mDepartments[i].name}
          </a>
        </li>
      {/section}
      </ul>
    </div>
    {* End departments list *}
    
    
    
    
    
    Code:
    {* categories_list.tpl *}
    {load_presentation_object filename="categories_list" assign="obj"}
    {* Start categories list *}
    <div class="box">
      <p class="box-title">Choose a Category</p>
      <ul>
      {section name=i loop=$obj->mCategories}
        {assign var=selected value=""}
        {if ($obj->mSelectedCategory == $obj->mCategories[i].category_id)}
          {assign var=selected value="class=\"selected\""}
        {/if}
        <li>
          <a {$selected} href="{$obj->mCategories[i].link_to_category}">
            {$obj->mCategories[i].name}
          </a>
        </li>
      {/section}
      </ul>
    </div>
    {* End categories list *}

  2. #2
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Once upon a time i used to use smarty, but since when MVC approach has been well adopted in PHP i just discarded it.
    One question: Why to use another templating engine if PHP itself is a kind of templating engine?
    May worth reading:
    http://hasin.wordpress.com/2008/01/0...re-was-smarty/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •