Fork me on GitHub

Programmically Change a Theme  Bottom

  • Does anyone know how to programmically change a theme in a module?

    Once apon a time you could just set $theme = "themename"; but that does not appear to work any more.

    Any ideas would be warmly welcomed

    Thanks
  • It still works, but you musy enable the "Let the users to switch the theme" in the Theme admin panel icon_wink

    --
    - Mateo T. -
    Mis principios... son mis fines
  • Thanks nestormateo,

    Is there a way of changing the theme for a page without enabling the users to change their themes?

    For example, a module where a particular user function uses the, say, SeaBreeze theme. But all other - default - functions use the system default.

    I know you can also just place &theme=name in the URL as well. But that is not what I am after. It is visible to the end user.

    There must be an easy way to assign/override the theme via code.

    Essentially what I want to do is print out a packing slip and invoice for a semi-ecommerce module. I don't want to use the "Printer" theme because it is the wrong format. And I don't want to change it as it is a core theme and doing so will effect other modules that use it.

    The other idea I had was looking at the domain.com/Printer redirect....
  • Looking at the htmlpages module, there is an option to display the printable version



    becomes


    The insertion of the "Printer", uses the Printer theme.

    Infact, all enabled themes can be used here in that format



    Of course turning OFF short URLs gives from above

    • http://domain.com/index.php?module=htmlpages&func=display&pid=1&theme=Printer


    So this works.

    BUT!!!!! It requires the theme to be written in the URL - not be programmically decided by in program logic.

    There should be a function like themeengine::settheme("themename")!
  • Make a Modul-Specific Template .
    Look here:http://community.zikula.org/index.php?module=Wiki&tag=TemplateOverridng

    --
    regards from germany

    High Quality Postnuke + Zikula Themes
  • Ooooh! Very interesting.

    However, this is a template override - not a full theme override. It will still use the existing theme and just change the template (ie the [!--[$content]--] part of the theme). I want to keep the template and change the theme.

    The stylesheet option is a possibility, but again, that does not change the theme layout (ie. blocks, header, footer).

    Nice idea though - thank you.

    What I really need is to be able to set a given theme for a given function - maybe even selecting a from choice of themes.

    We could do this once - all news of topic "News" was RedTheme - topic "Events" was BlueTheme. etc...

    Maybe that is where I need to look... can it still be done in the new Categories modules??

    The other thing I notice - completely on a tangent - is that the theme style sheets should come after the module style sheets. Since theme are the definitive end result.......



    edited by: geoff, datetimebrief
  • You can create different layouts within the same theme and assign them to different modules/sections. e.g. most theme have a home.htm for the homepage and a master.htm for the other pages, you can do the same thing for each module/function

    Go to Layout -> themes -> edit -> page configuration
    you can create as many different layout as you want

    --
    Zikula Italia
    SimpleGallery
  • I thought in the same way that Arthens
    but that would imply to support different "styles" in the same theme.
    Are you thinking on change the layout drastically to need a complete different theme?

    I'll check the core code to see if there's such possibility
    if not, we should have it for 1.3

    --
    - Mateo T. -
    Mis principios... son mis fines
  • 0 users

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