Fork me on GitHub

Watch

GitHub Core

Show your support for Zikula! Sign up at Github account and watch the Core project!




GitHub Modules

Forum Activity

Forum feed

» Visit forum | » View latest posts

Theme Page configurations  Bottom

  • 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
  • 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 icon_wink
    Just my 2 cents

    --
    - Mateo T. -
    Mis principios... son mis fines
  • 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.
  • 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
  • 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 ? icon_wink
    Philippe
  • 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:

    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'].'"';
    So you can define the colors on your theme CSS:

    Code

    .contentcategory-35 .z-content-page {
        background-color: #XXXXXX;
    }
    and use the plugin in your theme template(s) like:

    Code

    <body{pluginname}>


    But anyways, if you want an editable value via web, you can extend the code of the plugin like this:

    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;
    and use the plugin in your theme template(s) inside the head:

    Code

    {pluginname}</head>


    I'm including this code on BlankTheme example code icon_wink
    Hope it helps

    --
    - Mateo T. -
    Mis principios... son mis fines
  • 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.
  • icon_frown I cannot get rid of an error message saying:

    Quote

    PHP Fatal error: Call to a member function getRequest() on a non-object in ...
    it seems the plugin cannot get the requested URL.
  • It's Zikula 1.3 right?
    and the Smarty parameter of the plugin should be there so why the error?

    Code

    smarty_function_pluginname($params, &$smarty) {
    icon_confused

    --
    - Mateo T. -
    Mis principios... son mis fines
  • It's now working, don't know what happened icon_confused 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

This list is based on users active over the last 60 minutes.