Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Separate "embed theme" setting

Hi there,

I'm working on adding a separate setting for "embed themes".
I'm doing this in a fork at

Everything seems to be working fine, except that in "embed mode", the project is loading the wrong views.
Can someone point me to where it's decided which views to load?




  • Options

    Note forks of vanilla you are responsible for maintaining.

    What is the idea behind the fork? You could probably do what you want with a plugin.

    grep is your friend.

  • Options

    I'm kindof hoping that my commits will make it into the official branch.
    As far as I see, it was not possible to do this with a plugin.

    I basically want to select a theme for embedding, and a theme for regular view.
    Similar like the difference between the mobile theme and the regular theme.

    But if you can point me to where the view selection is done, I can finish it up and submit it for approval and hopefully get pulled into the main project.

  • Options

    It could be a wait for a pull request, and even then there is no guarantee, but it is sort of a reasonable request

    Plugin way would be to do a non-persistent configuration change. SaveToConfig('Garden.Theme',C('Garden.EmbedTheme'), FALSE) (note the false ensures it is not permanent)

    You need to set this at the right point though.

    grep is your friend.

  • Options

    Even so, how would I plugin anything in embed.js? :)
    Some sort of parameter will be required (although I am not sure how to handle this yet without making google unhappy)

  • Options

    You either add a second js file which overrides window.vanilla.embed or simply remove embed.js using RemoveJsFile() and Add your own with modifications.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    You can't use a separate them for embed. Embedding is simply adding an iframe of your existing forum. It is not a different forum , it is the same forum but in another iframe packaged inside javascript .

    You would need to modify based on detection of remote embed and I can't figure how that could be done. Then you would need to deal with the embed in mobile theme...

    Just find a good theme or make one that looks as you want .

  • Options
    BleistivtBleistivt Moderator
    edited November 2014

    It's not impossible, the embed script could pass an additional parameter that tells vanilla to use the embed theme and pages can determine wether they are iframed or not.

    The real problem though, is switching the theme, which is not entirely possible using a plugin.

    To actually switch the theme including its themehooks and template overrides, @daedeloth would have to create an application. And the theme switching will have to take place in the applications bootstrap.php

    The reason is this part:

    The ThemeManager starts before the PluginManager, so if there themehooks, they will already be included before PluginManager_Start, which is the earliest event. But applications are earlier.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Good luck with that @daedeloth , I would not bother constructing a thememanager by-pass app for the sake of an embed<<< (a potentially dysfunctional and minimaly working version of the actual Forum app )

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    @Bleistivt said:

    The ThemeManager starts before the PluginManager, so if there themehooks, they will already be included before PluginManager_Start, which is the earliest event. But applications are earlier.

    Haven't thought much about that, but couldn't adding a function to a themehook class be a solution? Something like:

    public function __construct() {
         if (forum == embedded) {
             serve C(Garden.EmbeddedTheme)
  • Options
    R_JR_J Ex-Fanboy Munich Admin

    Ah, I guess the answer to my question is "No, because themehooks of embedded theme wouldn't be executed."

    Forget it...

  • Options

    Ladies and gentlemen,

    I have finished my implementation.

    I think I sticked to all standards except for one tiny change that I'm not too happy about yet:
    class.request.php on line 916.
    I feel like that's the wrong place to patch things up.

    To see this in action: (bootstrap theme) (embed theme)

    I would be honoured to see this pulled into the main repo.
    Also it would safe me lots of maintenance work ;)


  • Options

    Hm, it appears I'm still doing something wrong.

    When I try to embed the forum itself:

    It loads the iframe with:

    So it's loading the correct theme apparently, but it's still loading the wrong views.

    Can anyone give me a clue to where I should fix this?

  • Options

    Actually, this is a bug.
    Mobile also doesn't use the correct view.

  • Options

    Are you sure?
    Do you mean the master view or view overrides?

    The mobile theme definitely loads the correct master view, and if view overrides wouldn't work, that would really surprise me.

  • Options
    daedelothdaedeloth New
    edited November 2014

    Sorry, I had introduced the issue myself earlier.
    It's been resolved now.

    I did notice an issue with mobile view settings.
    Might have gone unnoticed since the default mobile theme doesn't offer options.

    So, recap: => emedded forum => embedded comments

    I'll do some more testing, but looks good now.

    Consideration for pull is greatly appreciated.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    I can't see this getting traction as a PR. First, it sounds like a niche use-case. Second, I don't see anything that couldn't be easily wrapped in a plugin.

    This does sound like a wonderful plugin. I would highly suggest you re-wrap this as a plugin and distribute it here. The key thing you need to do, once you sanitize your input is to set the controller's theme before the render process starts. That is all you should need to do to get the theme looks.

    public function Base_Render_Before($Sender) {
      $ThemeName = 'soemthing';
      $Sender->Theme = $ThemeName;

    The only tricky part is determining the theme name as early as possible and unregister the current theme's hooks file and then registering the desired theme's hooks file.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    It doesn't make sense to have a mobile theme and not have an embed theme, imho.
    And it sounds like a very common case for everyone who is embeding the forum.

    And, well, there is another guy that wants to do the same thing posted in the last few days, so it doesn't sound so marginal to me ;)

  • Options

    Usually, when you embed your forum, you only want it to be accessed thorugh the page that acts as a container, so you'd choose the embed theme as your default.

    The embedded comments are an exception to that, though.
    The solution I presented in the other thread works with bootstrap, but won't be needed anymore, once bootstrap implements styling for the embedded comments.

    Generally I'd say it's the themes responsibility to make the embedded comments look right.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    An embed friendly theme only means that it is responsive and adjusts to the size of the container. Any theme can be an embed theme as long as it is responsive.

    Mobile themes are also responsive in nature in that the window adjusts to the size of the device . You can make a single theme for both mobile and desktop. However it is tricky to do so unless you know how to target specific media with @media CSS .

Sign In or Register to comment.