Frequently Asked Questions v2 |
FAQ Main / Browse by Category |
This example uses 1 view, 3 categories, and 2 levels of constants. The catgories are not important but maybe you like to use them so I left them in there.
The view below manages a two level side bar menu. It highlights the branch you are in and the (sub)item you have selected. Example can be seen here http://pi.gn.apc.org
The constants are used as the menu entries. You have to use hierarchical constants and define the constants like this:
Level 0: Name Value Terrorism Terrorism Policy Policy ... Level 1: Name Value Politics of Terrorism Terrorism::Politics of Terrorism Defining Terrorism and Emergencies Terrorism::Terrorism and Emergencies IGOs and Laundering Policy Policy::IGOs and Laundering Policy ...
Now create a new constants view Paste the text below into Odd Rows. Set the Group by to "Value Select" the hierarchical constant group created above View 342 is the listing view I use to display items from my slice.
The slice has 3 categories. This menu only manages the selection of the first category (category........) which is set to use the constant group created above. Further it's first confition is set to LIKE (name of category........). You will have to replace 342 in the text below with your listing view. You can leave away most of the {country}-stuff. To work this just needs {theme} and {_parent_}.
TODO: use better names for the aliases. 'theme' and 'country' might be substrings in the constants. That would cause havoc! All left to do now is to create your style sheet. Have fun!
----------SNIP SNIP----------
{switch({_#LEVEL##_})0:<br> {switch({theme}).*theme.*: <div class="constView_ContentThemes_ListEntry"> :{_#NAME###_}.*: <div class="constView_ContentThemes_ListEntry_Hl"> :<div class="constView_ContentThemes_ListEntry{switch({_parent_}){_#NAME###_}.*:_Hl}"> } <a href="/index.shtml?cmd[342][]=c-1-{_#NAME###_}&als[theme]={_#NAME###_}&conds[1][category........]={_#NAME###_}{switch({_#VALUE##_}){theme}.*:&als[_parent_]={theme}}{switch({country}).*country.*::&cmd[342][]=c-3-{country}&als[country]={country}&conds[3][category.......2]={country}}" class="constView_ContentThemes_ListEntry_link">_#NAME###_</a> </div> :1:<!--{theme}--_#VALUE##_--_#NAME###_--> {switch({_parent_}).*_parent_.*: {switch({theme}).*theme.*:: {switch({_#VALUE##_}){theme}.*:<div class="constView_ContentThemes_SubListEntry{switch({theme}){_#NAME###_}.*:_Hl}"><a href="/index.shtml?cmd[342][]=c-1-{_#NAME###_}&als[theme]={_#NAME###_}&conds[1][category........]={_#NAME###_}&als[_parent_]={theme}{switch({country}).*country.*::&cmd[342][]=c-3-{country}&als[country]={country}&conds[3][category.......2]={country}}" class="constView_ContentThemes_SubListEntry_link">{_#NAME###_}</a></div>} } :{switch({theme}).*theme.*:: {switch({_#VALUE##_}){_parent_}.*:<div class="constView_ContentThemes_SubListEntry{switch({theme}){_#NAME###_}.*:_Hl}"><a href="/index.shtml?cmd[342][]=c-1-{_#NAME###_}&als[theme]={_#NAME###_}&conds[1][category........]={_#NAME###_}&als[_parent_]={_parent_}{switch({country}).*country.*::&cmd[342][]=c-3-{country}&als[country]={country}&conds[3][category.......2]={country}}" class="constView_ContentThemes_SubListEntry_link">{_#NAME###_}</a></div>} } } }
----------SNIP SNIP----------
Some fields have a predefined set of possible values --- a constant group. These are usually shown in a select box, multiple check / radio boxes etc. Edit them in Slice Admin -- Fields -- Constants -- Edit / New.
Categories are constants with some special properties. The constant table structure is:
CREATE TABLE constant (
id char(16) NOT NULL,
group_id char(16) NOT NULL,
name char(150) NOT NULL,
value char(150) NOT NULL,
class char(16),
pri smallint(5) DEFAULT '100' NOT NULL,
PRIMARY KEY (id),
KEY group_id (group_id)
);
For example the "State" select box (if you want to see it on input form) has the names and values of:
Name | Value |
Approved bin | 1 |
Holding bin | 2 |
Trash bin | 3 |
Another example, more real-life - colors select box. There can be names of "Red", "blue", "very bright green", ... and values will be "#FF0000", "#0000FF", "#EEFFEE". In input form you see Red... and on page is then #FF0000
The third example is kind of hint. Suppose you want to have different kinds of item - for example "public", "private", "other" and you want to see this words on compact view. No problem, but you want to see each in different color. So you can define:
name: PrivateYou can set the priority order in the constant editing page, and then if you want the output in this order as well, then in the View set the sorting to be "Ascending (or Descending) by Priority"
Usually if you change a constant value, the current items in the database remain the same. By checking this box you force the changes to be made on the items too. If you change "red" to "cyan", all items with color "red" will be changed to "cyan".
Remember that the constants may be shared by several slices --- if you change a value, the changes may be propagated to some places which you didn't count with. Another danger is that if there were some items with "cyan" before, you can never ever find which item are converted from "red" and which are not.
Changing the constant name doesn't have any effect in the database but changes the look in all Edit / New item pages using the constant group.
_#NAME###_ | const_name | Constant name |
_#VALUE##_ | const_value | Constant value |
_#PRIORITY | const_pri | Constant priority |
_#GROUP##_ | const_group | Constant group id |
_#CLASS##_ | const_class | Category class (for categories only) |
_#COUNTER_ | Constant number | |
_#CONST_ID | const_id | Constant unique id (32-haxadecimal characters) |
_#SHORT_ID | const_short_id | Constant unique short id (autoincremented from '1' for each constant in the system) |
_#DESCRIPT | const_description | Constant description |
_#LEVEL##_ | const_level | Constant level (used for hierachical constants). If you want to display hierarchical constants in its hierarchy (so constant on second level have two spaces before the name), you can use following AA expression:{switch({_#LEVEL##_})1: :2: :3: } |
This FAQ interface was developed by Jason at Commons.ca
|
APC
ActionApps is a free software content management system initiated by
the Association for Progressive Communications (APC) APC - Internet and ICTs for social justice and development |