- Posts: 58
COMMUNITY FORUM
Where do I find a list of all K2 parameter names?
- Timothy Michel
-
Topic Author
- Offline
- Senior Member
Less
More
10 years 11 months ago #128758
by Timothy Michel
Where do I find a list of all K2 parameter names? was created by Timothy Michel
For Instance, what are the parameters that go with "if ($this->params->get('catTitleItemCounter')" if I want to restrict the inclusion of content with something like: $this->itemCounter > 1. Is itemCounter the correct param that goes with get('catTitleItemCounter'), or where do Iocate these?.
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
10 years 11 months ago #128759
by Lefteris
Replied by Lefteris on topic Re: Where do I find a list of all K2 parameter names?
Hi. The parameters are the variables that come from call like: $params->get('PARAM_NAME') . They are all defined in XML files inside K2. They are divided in three types:
1. Global K2 parameters. You can find them at administrator/components/com_k2/config.xml
2. Category and item parameters. You can find them at administrator/components/com_k2/models/category.xml and administrator/components/com_k2/models/item.xml.
3. Menu link parameters. You can find them under components/com_k2/view/VIEW_NAME/tmpl/LAYOUT_NAME.xml.
Note that these parameters are merged during the runtime depending on context. Regarding the rest variables you see in the template files they either come from the database or are computed during runtime in the view.html.php file of the current view.
1. Global K2 parameters. You can find them at administrator/components/com_k2/config.xml
2. Category and item parameters. You can find them at administrator/components/com_k2/models/category.xml and administrator/components/com_k2/models/item.xml.
3. Menu link parameters. You can find them under components/com_k2/view/VIEW_NAME/tmpl/LAYOUT_NAME.xml.
Note that these parameters are merged during the runtime depending on context. Regarding the rest variables you see in the template files they either come from the database or are computed during runtime in the view.html.php file of the current view.
Please Log in or Create an account to join the conversation.
- Timothy Michel
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 58
10 years 11 months ago #128760
by Timothy Michel
Replied by Timothy Michel on topic Re: Where do I find a list of all K2 parameter names?
Thank you, I will print these out and tape them to my forehead.
Please Log in or Create an account to join the conversation.
- Timothy Michel
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 58
10 years 11 months ago - 10 years 11 months ago #128761
by Timothy Michel
Replied by Timothy Michel on topic Re: Where do I find a list of all K2 parameter names?
This is what I settled on:
<?php if($this->params->get('catTitle')): ?>
<!-- Category title -->
<h2><?php echo $this->category->name; ?></h2><?php if($this->params->get('catTitleItemCounter') && $this->pagination->total==1) {echo '<h4 style="color:#a09db1;margin-top:-2.25em;text-shadow:none"><br />(There is 1 item in this section)</h4>';} elseif(!$this->params->get('catTitleItemCounter') && $this->pagination->total==1){ echo '<h4 style="color:#a09db1;margin-top:-2.25em;text-shadow:none"><br />(There are no items in this section yet)</h4>';} else {echo '<h4 style="color:#a09db1;margin-top:-2.25em;text-shadow:none"><br />(There are '.$this->pagination->total.' items in this section)</h4>';} ?>
<?php endif; ?>
I really don't understand this, can someone explain to me why this works?? I created it, but I don't understand what is going on.
catTitleItemCounter is set in params to display or not display, 1, 0; $this->pagination->total counts anything that produces a page including sub-categories and items. Yes I should remove the styles to css, I will do that later.
Is there a way to test for items/articles only and not items + sub-categories? In other word if a category contains 10 sub-categories but none of the subcategories contain any items/articles, is there a way to test for that?
<?php if($this->params->get('catTitle')): ?>
<!-- Category title -->
<h2><?php echo $this->category->name; ?></h2><?php if($this->params->get('catTitleItemCounter') && $this->pagination->total==1) {echo '<h4 style="color:#a09db1;margin-top:-2.25em;text-shadow:none"><br />(There is 1 item in this section)</h4>';} elseif(!$this->params->get('catTitleItemCounter') && $this->pagination->total==1){ echo '<h4 style="color:#a09db1;margin-top:-2.25em;text-shadow:none"><br />(There are no items in this section yet)</h4>';} else {echo '<h4 style="color:#a09db1;margin-top:-2.25em;text-shadow:none"><br />(There are '.$this->pagination->total.' items in this section)</h4>';} ?>
<?php endif; ?>
I really don't understand this, can someone explain to me why this works?? I created it, but I don't understand what is going on.
catTitleItemCounter is set in params to display or not display, 1, 0; $this->pagination->total counts anything that produces a page including sub-categories and items. Yes I should remove the styles to css, I will do that later.
Is there a way to test for items/articles only and not items + sub-categories? In other word if a category contains 10 sub-categories but none of the subcategories contain any items/articles, is there a way to test for that?
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
10 years 11 months ago #128762
by Lefteris
Replied by Lefteris on topic Re: Where do I find a list of all K2 parameter names?
The following variable holds the number of items of each subcategory inside the loop:
$subCategory->numOfItems
Please Log in or Create an account to join the conversation.
- Timothy Michel
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 58
10 years 11 months ago #128763
by Timothy Michel
Replied by Timothy Michel on topic Re: Where do I find a list of all K2 parameter names?
But it has only function scope.
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
10 years 11 months ago #128764
by Lefteris
Replied by Lefteris on topic Re: Where do I find a list of all K2 parameter names?
Yes. If you want to use it somewhere else you will have to query the database.
Please Log in or Create an account to join the conversation.