Dear all,
we are currently preparing a new public portal using Zikula1.3. Most of the pages will use the Content module. So we have sorted and structured our content into 5 categories (1 general and 4 sub communities). The idea is to use a color corresponding to each community and to also associate specific blocks content.
In order to do that I now use Page configurations assignment like that:
Content/user/view/pid=2 community1.ini
But, instead of assigning one config to one page, is there a way to specify a Zikula category? Or something more dynamic...
Thanks for your tips.
Philippe
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- drak responded to »What's going on with 1. the documentation | 2. the AppStore« 23. May
- Paustian responded to »Shared user database« 23. May
- Paustian responded to »Problems: module "htmlpages« 23. May
- bronto responded to »Forcing a theme for particular URLs« 22. May
- Paustian created topic »Dealing with a Huge User List« 21. May
- Paustian responded to »Manual Zikula 1.2.9 (dev) to Zikula 1.3.5 update« 21. May
- krator responded to »Refresh Templates/Cache« 19. May
Login
Theme Page configurations
-
- Rank: Softmore
- Registered: Jan 24, 2006
- Last visit: Apr 19, 2010
- Posts: 178
-
- Rank: Team Member
- Registered: Sep 06, 2006
- Last visit: May 09, 2010
- Posts: 2447
From my point of view
a theme plugin to add a CSS class to the BODY, depending on the category, when Content is displaying a page, should work, but that will need SQL query from the theme, hopefully the same used by Content, so it can be cached
Just my 2 cents
--
- Mateo T. -
Mis principios... son mis fines -
- Rank: Softmore
- Registered: Jan 24, 2006
- Last visit: Apr 19, 2010
- Posts: 178
mateo
a theme plugin to add a CSS class to the BODY
Done and working. I have created theme palette variables in order to load the corresponding CSS styles.
I wanted to assign them automatically via a specific attribute added to each Zikula category but attributes seem not to be part of the accessible template variables (checked with zdebug).
So, as you say I need a SQL request included in the theme to get value. Do you have a sample of an SQL request included in the theme? can I add PHP code? Or I see I can already use $page.categoryId .
Thanks for your help,
Philippe
Edited by pnFilip on Apr 06, 2011 - 02:04 PM. -
- Rank: Team Member
- Registered: Jan 05, 2003
- Last visit: May 28, 2010
- Posts: 868
Quote
I wanted to assign them automatically via a specific attribute added to each Zikula category but attributes seem not to be part of the accessible template variables (checked with zdebug).
Why not just use the 'value' category field? It's typically unused and perfectly suitable for this type of use.
Greetings
R -
- Rank: Softmore
- Registered: Jan 24, 2006
- Last visit: Apr 19, 2010
- Posts: 178
Yes, this is what I said here :
Quote
Or I see I can already use $page.categoryId .
But I wanted to retrieve the color value directly from the category attributes in order to be able to modify them without adding manual tests (if catID=X then $palette=Y) in my theme. Nicer solution, isn't it ?
Philippe -
- Rank: Team Member
- Registered: Sep 06, 2006
- Last visit: May 09, 2010
- Posts: 2447
I suggest a CSS solution, because your solution seems to need an additional DB query (the core may perform 2 queries) to fetch the Category attribute, so, it can be like:
So you can define the colors on your theme CSS:Code
if (system::getVar('shorturls') == '1' && system::getVar('shorturlstype') == '0') {
$urlname = $smarty->getRequest()->getGet()->get('name');
$pageId = ModUtil::apiFunc('Content', 'Page', 'solveURLPath', compact('urlname'));
} else {
$pageId = $smarty->getRequest()->getGet()->get('pid');
}
$page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $pageId));
// Possibility 1: build a CSS class
return ' class="contentcategory-'.$page['categoryId'].'"';
and use the plugin in your theme template(s) like:Code
.contentcategory-35 .z-content-page {
background-color: #XXXXXX;
}
Code
<body{pluginname}>
But anyways, if you want an editable value via web, you can extend the code of the plugin like this:
and use the plugin in your theme template(s) inside the head:Code
// Possibility 2: extract the category attribute
$code = '';
if (!empty($page['categoryId'])) {
$cat = CategoryUtil::getCategoryByID($page['categoryId'])
$color = $cat['__ATTRIBUTES__']['contentcolor'];
$code = "<style>
.contentcategory-35 .z-content-page {
background-color: $color;
}
</style>";
}
return $code;
Code
{pluginname}</head>
I'm including this code on BlankTheme example code
Hope it helps
--
- Mateo T. -
Mis principios... son mis fines -
- Rank: Softmore
- Registered: Jan 24, 2006
- Last visit: Apr 19, 2010
- Posts: 178
Thanks Mateo, I now understand why I need additional SQL request or Content API calls. When I need the body class variable (possibility 1) at this moment the page is not "computed" through the Content module and I don't have access to the template variables $page.categoryId . Is that right?
Sorry I am a bit slow. Anyway I will try your suggestions.
Thanks a lot. -
- Rank: Softmore
- Registered: Jan 24, 2006
- Last visit: Apr 19, 2010
- Posts: 178
I cannot get rid of an error message saying:
it seems the plugin cannot get the requested URL.Quote
PHP Fatal error: Call to a member function getRequest() on a non-object in ...
-
- Rank: Team Member
- Registered: Sep 06, 2006
- Last visit: May 09, 2010
- Posts: 2447
-
- Rank: Softmore
- Registered: Jan 24, 2006
- Last visit: Apr 19, 2010
- Posts: 178
It's now working, don't know what happened
In between, I have cleared all caches, changed the default theme.
Thanks, I have used in my theme the same plugin to select the correct the "Login" URL and to activate the CSS class of the corresponding menu item too.
Great!!!
Philippe
- Moderated by:
- Support
