Code: Select all
<!-- categories -->
<ul>
{foreach from=$categories item=category}
<li class="category-{$category->alias}">
<a class="category-name" href="{$category->url}">{$category->name} ({$category->items|count})</a>
{if !empty($category->description)}
<div class="category-description">
{eval var=$category->description}
</div>
{/if}
</li>
{/foreach}
<ul>
<!-- categories //-->
Using {get_template_vars} provides something that looks like this:
Code: Select all
$SCRIPT_NAME (string) = /index.php
$app_name (string) = callable
$sitename (string) = mywebsite
$content_obj (object of type: Content) = {}
$content_id (string) = 27
$page_id (integer) = 27
$page_alias (string) = downloads
$lang (string) = en_US
$encoding (string) = utf-8
$content (string) =
$current_category (object of type: LISECategory) = {
.category_id (string) = 1
.alias (string) = cat_specs
.name (string) = Equipment Specs
.description (string) =
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque rutrum pellentesque imperdiet. Nulla lacinia iaculis nulla non pulvinar. Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut eu risus enim, ut pulvinar lectus. Sed hendrerit nibh metus.
.active (string) = 1
.position (string) = 1
.parent_id (string) = -1
.hierarchy (string) = 00001
.id_hierarchy (string) = 1
.hierarchy_path (string) = cat_specs
.create_date (string) = 2016-10-24 19:48:18
.modified_date (string) = 2016-10-24 21:54:17
.key1 (NULL) =
.key2 (NULL) =
.key3 (NULL) =
->items (array) = [
.0 (string) = 1
.1 (string) = 2
]
->children (array) = [
]
.depth (integer) = 1
.prevdepth (integer) = 1
.url (string) = http://mywebsite/index.php/documents/cat_specs/1/27
.index (integer) = 0
.menutext (string) = Equipment Specs
.parent (boolean) =
.current (boolean) =
}
$smarty (NULL) =
$actionid (string) = mb38af
$actionparams (array) = [
.action (string) = default
.module (string) = LISEDocuments
]
$returnid (string) = 27
$actionmodule (string) = LISEDocuments
$mod (object of type: LISEDocuments) = {
.prefix (string) = documents
.use_hints (NULL) =
}
$categories (array) = [
[0] (object of type: LISECategory) = {
.category_id (string) = 1
.alias (string) = cat_specs
.name (string) = Equipment Specs
.description (string) =
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque rutrum pellentesque imperdiet. Nulla lacinia iaculis nulla non pulvinar. Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut eu risus enim, ut pulvinar lectus. Sed hendrerit nibh metus.
.active (string) = 1
.position (string) = 1
.parent_id (string) = -1
.hierarchy (string) = 00001
.id_hierarchy (string) = 1
.hierarchy_path (string) = cat_specs
.create_date (string) = 2016-10-24 19:48:18
.modified_date (string) = 2016-10-24 21:54:17
.key1 (NULL) =
.key2 (NULL) =
.key3 (NULL) =
->items (array) = [
.0 (string) = 1
.1 (string) = 2
]
->children (array) = [
]
.depth (integer) = 1
.prevdepth (integer) = 1
.url (string) = http://mywebsite/index.php/documents/cat_specs/1/27
.index (integer) = 0
.menutext (string) = Equipment Specs
.parent (boolean) =
.current (boolean) =
}
[1] (object of type: LISEItem) = {
.item_id (string) = 1
.alias (string) = test-document-1
.title (string) = Test Document 1
.url (string) = http://mywebsite/index.php/documents/cat_specs/1/test-document-1/27
.position (string) = 5
.active (string) = 1
.create_time (string) = 2016-10-12 07:26:42
.modified_time (string) = 2016-10-24 19:49:26
.start_time (NULL) =
.end_time (NULL) =
.owner (string) = 2
.key1 (NULL) =
.key2 (NULL) =
.key3 (NULL) =
->fielddefs (object of type: LISEFielddefArray) = { }
.depth (integer) = 2
.prevdepth (integer) = 1
.index (integer) = 1
.menutext (string) = Test Document 1
.parent (boolean) =
.current (boolean) =
}
[2] (object of type: LISEItem) = {
.item_id (string) = 2
.alias (string) = test-document-2
.title (string) = Test Document 2
.url (string) = http://mywebsite/index.php/documents/cat_specs/1/test-document-2/27
.position (string) = 6
.active (string) = 1
.create_time (string) = 2016-10-12 07:31:07
.modified_time (string) = 2016-10-24 19:49:35
.start_time (NULL) =
.end_time (NULL) =
.owner (string) = 2
.key1 (NULL) =
.key2 (NULL) =
.key3 (NULL) =
->fielddefs (object of type: LISEFielddefArray) = { }
.depth (integer) = 2
.prevdepth (integer) = 2
.index (integer) = 2
.menutext (string) = Test Document 2
.parent (boolean) =
.current (boolean) =
}
[3] (object of type: LISECategory) = {
.category_id (string) = 2
.alias (string) = cat_corporate
.name (string) = Corporate Documents
.description (string) =
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque rutrum pellentesque imperdiet. Nulla lacinia iaculis nulla non pulvinar. Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut eu risus enim, ut pulvinar lectus. Sed hendrerit nibh metus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque rutrum pellentesque imperdiet. Nulla lacinia iaculis nulla non pulvinar. Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut eu risus enim, ut pulvinar lectus. Sed hendrerit nibh metus.
.active (string) = 1
.position (string) = 2
.parent_id (string) = -1
.hierarchy (string) = 00002
.id_hierarchy (string) = 2
.hierarchy_path (string) = cat_corporate
.create_date (string) = 2016-10-24 19:49:09
.modified_date (string) = 2016-10-24 21:54:25
.key1 (NULL) =
.key2 (NULL) =
.key3 (NULL) =
->items (array) = [
.0 (string) = 3
.1 (string) = 4
.2 (string) = 5
.3 (string) = 6
.4 (string) = 7
]
->children (array) = [
]
.depth (integer) = 1
.prevdepth (integer) = 2
.url (string) = http://mywebsite/index.php/documents/cat_corporate/2/27
.index (integer) = 3
.menutext (string) = Corporate Documents
.parent (boolean) =
.current (boolean) =
}
[4] (object of type: LISEItem) = {
.item_id (string) = 3
.alias (string) = corporate-brochure
.title (string) = Corporate Brochure
.url (string) = http://mywebsite/index.php/documents/cat_corporate/2/corporate-brochure/27
.position (string) = 0
.active (string) = 1
.create_time (string) = 2016-10-12 07:35:06
.modified_time (string) = 2016-10-24 19:52:17
.start_time (NULL) =
.end_time (NULL) =
.owner (string) = 2
.key1 (NULL) =
.key2 (NULL) =
.key3 (NULL) =
->fielddefs (object of type: LISEFielddefArray) = { }
.depth (integer) = 2
.prevdepth (integer) = 1
.index (integer) = 4
.menutext (string) = Corporate Brochure
.parent (boolean) =
.current (boolean) =
}
[5] (object of type: LISEItem) = {
.item_id (string) = 4
.alias (string) = the-way
.title (string) = The Way
.url (string) = http:///index.php/documents/cat_corporate/2/the-way/27
.position (string) = 1
.active (string) = 1
.create_time (string) = 2016-10-12 07:36:09
.modified_time (string) = 2016-10-24 19:52:53
.start_time (NULL) =
.end_time (NULL) =
.owner (string) = 2
.key1 (NULL) =
.key2 (NULL) =
.key3 (NULL) =
->fielddefs (object of type: LISEFielddefArray) = { }
.depth (integer) = 2
.prevdepth (integer) = 2
.index (integer) = 5
.menutext (string) =
.parent (boolean) =
.current (boolean) =
}
[6] (object of type: LISEItem) = {
.item_id (string) = 5
.alias (string) = mission-statement
.title (string) = Mission Statement
.url (string) = http://mywebsite/index.php/documents/cat_corporate/2/mission-statement/27
.position (string) = 2
.active (string) = 1
.create_time (string) = 2016-10-12 07:37:20
.modified_time (string) = 2016-10-24 19:51:38
.start_time (NULL) =
.end_time (NULL) =
.owner (string) = 2
.key1 (NULL) =
.key2 (NULL) =
.key3 (NULL) =
->fielddefs (object of type: LISEFielddefArray) = { }
.depth (integer) = 2
.prevdepth (integer) = 2
.index (integer) = 6
.menutext (string) = Mission Statement
.parent (boolean) =
.current (boolean) =
}
[7] (object of type: LISEItem) = {
.item_id (string) = 6
.alias (string) = policy-statement
.title (string) = Policy Statement
.url (string) = http://mywebsite/index.php/documents/cat_corporate/2/policy-statement/27
.position (string) = 3
.active (string) = 1
.create_time (string) = 2016-10-12 07:38:21
.modified_time (string) = 2016-10-24 19:52:32
.start_time (NULL) =
.end_time (NULL) =
.owner (string) = 2
.key1 (NULL) =
.key2 (NULL) =
.key3 (NULL) =
->fielddefs (object of type: LISEFielddefArray) = { }
.depth (integer) = 2
.prevdepth (integer) = 2
.index (integer) = 7
.menutext (string) = Policy Statement
.parent (boolean) =
.current (boolean) =
}
[8] (object of type: LISEItem) = {
.item_id (string) = 7
.alias (string) = management-system
.title (string) = Management System
.url (string) = http://mywebsite/index.php/documents/cat_corporate/2/management-system/27
.position (string) = 4
.active (string) = 1
.create_time (string) = 2016-10-12 07:39:34
.modified_time (string) = 2016-10-24 19:52:42
.start_time (NULL) =
.end_time (NULL) =
.owner (string) = 2
.key1 (NULL) =
.key2 (NULL) =
.key3 (NULL) =
->fielddefs (object of type: LISEFielddefArray) = { }
.depth (integer) = 2
.prevdepth (integer) = 2
.index (integer) = 8
.menutext (string) = Management System
.parent (boolean) =
.current (boolean) =
}
[9] (object of type: LISECategory) = {
.category_id (string) = 3
.alias (string) = cat_other
.name (string) = Other
.description (string) =
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque rutrum pellentesque imperdiet. Nulla lacinia iaculis nulla non pulvinar. Sociis natoque penatibus et magnis dis parturient montes.
.active (string) = 1
.position (string) = 3
.parent_id (string) = -1
.hierarchy (string) = 00003
.id_hierarchy (string) = 3
.hierarchy_path (string) = cat_other
.create_date (string) = 2016-10-24 21:12:55
.modified_date (string) = 2016-10-24 21:54:35
.key1 (NULL) =
.key2 (NULL) =
.key3 (NULL) =
->items (array) = [
]
->children (array) = [
]
.depth (integer) = 1
.prevdepth (integer) = 2
.url (string) = http://mywebsite/index.php/documents/cat_other/3/27
.index (integer) = 9
.menutext (string) = Other
.parent (boolean) =
.current (boolean) =
}
]
Thanks.
Edit:
This gets me the item ID but I cannot figure out how to get the rest of the item data - like name, alias, description, etc.
Code: Select all
{foreach from=$categories item=category}
{foreach $category->items item=item}
{$item}
{/foreach}
{/foreach}
What am I missing?
Edit #2:
I've modified it a bit to look like this:
Code: Select all
{foreach from=$categories item=category}
{foreach from=$category item=item}
{$item.type}
{/foreach}
{/foreach}
If I change it to just {$item} instead of {$item.type} I get:
Code: Select all
1 1 -1 00001 1 cat_specs 2016-10-24 19:48:18 2016-10-24 21:54:17 Array Array 1 1 http://mywebsite/index.php/documents/cat_specs/1/27 0 Equipment Specs
Edit #3
If I change it to reflect more of what smarty.net suggests in respect to drilling into arrays, I get a similar garbage output that only references the category elements - not the items.
Code: Select all
{foreach from=$category item=item key=key}
{foreach from=$item item=this key=that}
{$this} : {$that}
{/foreach}
{/foreach}