LemonStand Version 1 Has Been Discontinued
This documentation is for LemonStand Version 1. LemonStand is now offered as a cloud-based eCommerce platform.
You can try the new LemonStand and learn about upgrading here.
Generating Site Maps
Displaying a full site map
Let's create a simple list-based website map. First, create a new page and assign it some title and URL, for example /site_map. This page will contain the website map. As the site map will be based on lists, we will need a UL element. Also, we will need a partial, which will display elements of the website map. Insert the following code to the Content field of the site map page:
<ul> <? $this->render_partial('sitemap_pages', array('pages'=>$this->page->navigation_root_pages())) ?> </ul>
<ul> {{ render_partial('sitemap_pages', {'pages': this.page.navigation_root_pages()}) }} </ul>
This code triggers the sitemap_pages partial rendering and passes a list of the root website pages to it. The list of root pages is obtained using the navigation_root_pages() method of the Cms_Page object, which is always accessible through the $page field of the Cms_Controller class (the $this variable).
Now we need to create the sitemap_pages partial. Create a partial with this name and paste the following code to the HTML Code field:
<? foreach ($pages as $page): ?> <li> <a href="<?= $page->url ?>"><?= h($page->navigation_label()) ?></a> </li> <? endforeach ?>
{% for page in pages %} <li> <a href="{{ page.url }}">{{ page.navigation_label() }}</a> </li> {% endfor %}
The code iterates through the $pages array which we passed from the site map page. For each page the code outputs a link and a title. The page title is obtained using the navigation_label() method. This method returns a Menu Label field of a page object. In case if the Menu Label field is empty, the method returns the page title.
Save the partial and navigate to the site map page. You will see a list of the website root pages.
Next: Generating Breadcrumbs
Previous: Using Twig Templating Engine
Return to LemonStand Back-End