Template Modifcations

  • App
    WoltLab Suite Forum

    I want Woltlab to be easier to use and customize. One thing I like about EVERY development (vBulletin, IP.Board, XenForo, phpBB, ect...) is you can edit templates to achieve fairly easy customizations and modifications without having to code php or making a stand alone plugin.

    For example, I have come to believe there is no easy way to hide the "who is online page" from people.
    Hide and deny access to who is online page?

    This is a really simple thing to do in vBulletin, IP.Board, phpBB, and XenForo and it can be done with a single template edit. A total of 3 lines of code in a template and you're done. You can even extend the template code to select user groups.

    I would like to bring that ease of functionality and customization to Woltlab :)

  • You already can do this...
    Read the thread:

    Instead just create a new template group, copy over the template and apply your modifications to that file. Next edit your style to make use of that template group and you're done. Benefits of this approach: The system will check this group first when looking for the template, if it doesn't exist it will access the original template, thus you don't need to copy everything. Next these custom template groups will never be touched by the system, regardless what the update does, the custom template will be unmodified.

    The only thing is, if you use a style wich is already connectet to a template group, you have to add the modified templates also to those.
    If you use a less only style (wich are indeed many in the store) you could simply use the same template group in every style.

  • You already can do this...
    Read the thread:

    The only thing is, if you use a style wich is already connectet to a template group, you have to add the modified templates also to those.If you use a less only style (wich are indeed many in the store) you could simply use the same template group in every style.

    • So how would you edit a template... ie... Change something in an existing template?
    • How would you comment something out?
    • How would you define something to work in only X conditions?
    • How would you apply a change to all styles?

    I would not call this a template modification system, because to my knowledge you cannot do any of the above.

    • Offizieller Beitrag

    So how would you edit a template... ie... Change something in an existing template?

    Follow my instructions above.

    How would you comment something out?

    Either by wrapping it inside {* … *} or completely remove that part from the template. Do whichever option suits your needs best.

    How would you define something to work in only X conditions?

    Depends on what you want to achieve, e.g. hiding parts for guests: {if $__wcf->getUser()->userID} This is not visible to guests. {/if}

    How would you apply a change to all styles?

    Template Groups can inherit from another template group. This means you can create a global template group where all style-specific groups inherit from. This way you can make a change to the template in the global group and the change will then affect all styles at once.

  • Code
    {if !$__wcf->session->getPermission('admin.general.canUseAcp')}
    	This is visible to all users (guests and logged-in) unless they have the permission to access the ACP.
    {/if}

    OK... So again, not a template modification system... How do you define permissions via a template?

    This is why I'm going crazy trying to do this and appear to be failing. It's very frustrating.
    Hide and deny access to who is online page?

    I want so that X is only viewable to Y. I want to be able to see the who is online page, but do not want others who are not staff to see it.

    I want everyone else to see this

  • For example in vBulletin....


    @Alexander Ebert

    HTML
    <if condition="$show['member']">You're a member! A guest won't see this</if>
    <if condition="$show['guest']">You're not yet registered/logged in</if>

    You can use in_array for example to match against available usergroups a member is member off:
    <if condition="is_member_of($bbuserinfo, 5, 7, 19, 16)">You're seeing this because you're a member of a particular usergroup</if>

  • So how about everyone except administrators?

    Question is, who in your opinion is an administrator?

    There are numerous way to check for that. Alexander chose to check for the permission that the user can use the ACP, as it is reasonable to assume that someone who is dubbed "administrator" can do that. If you knew that for example the administrator group has the ID 6 (that is, the group named "Administrator"), you could check wether this user is in the group with that ID. Or you could check for whatever it is that qualifies the user - in your opinion - to be an administrator.
    The reason Alex chose to check for an permission is that is is way more elegant then to hard-code the check for an specific ID. It works with multiple groups that are admins, it works regardless of what those groups actually are and more.

    OK... So again, not a template modification system...

    That is a template modification, you can use that as-is in a template.

    "A life is like a garden. Perfect moments can be had, but not preserved, except in memory. LLAP" — Leonard Nimoy

  • You know that templates represent the “presentation” and not the “data” layer, do you?

    I'm gathering that... To much to my great disappointment. :(

    Which is why I requested to have a full template modification system, because in vBulletin, XenForo, IP.Board, phpBB, SMF, ect.. I can edit 1 single template without having to learn the php structure of WBB and without coding files (which I don't have time for).

    In vBulletin, XenForo, IP.Board it is as simple as 1 small template edit and done. It's easy and you're onto your next task in seconds. This is what I would want for Woltlab, to become more user friendly so that even a newbie could do it.

  • You can use in_array for example to match against available usergroups a member is member off:

    You can use in_array in WCF/Smarty, too.

    <if condition="is_member_of($bbuserinfo, 5, 7, 19, 16)">You're seeing this because you're a member of a particular usergroup</if>
    becomes
    {assign var=groupIDs value= "5,7,19,16"|explode} {if $__wcf->getUser()->getGroupIDs()|in_array:$groupIDs}You're seeing this because you're a member of a particular usergroup{/if}

    There migh even be a more clean way without the additional assign, but that should work.

    "A life is like a garden. Perfect moments can be had, but not preserved, except in memory. LLAP" — Leonard Nimoy

  • Yes, it surely is.

    - If you don't want to links to the user online list to appear in the template, just remove them from the template or surround them in {if...} ... {/if} block with some condition on whom should see them and who not.
    - Do the same with the entire template of the user online list

    Done ;)

    Of course you can always make that more elegant and escalate it into a plugin that defines his own permission, check for that permission and use an EL to fire a PermissionDeniedException, but I honestly wouldn't bother if all that I wanted was hiding a page.

    But you should do it via the ACP and your own template group, otherwise updates might override your changes. Never edit files directly in the file system.

    "A life is like a garden. Perfect moments can be had, but not preserved, except in memory. LLAP" — Leonard Nimoy

  • You can use in_array in WCF/Smarty, too.
    <if condition="is_member_of($bbuserinfo, 5, 7, 19, 16)">You're seeing this because you're a member of a particular usergroup</if>
    becomes
    {assign var=groupIDs value= "5,7,19,16"|explode} {if $__wcf->getUser()->getGroupIDs()|in_array:$groupIDs}You're seeing this because you're a member of a particular usergroup{/if}

    There migh even be a more clean way without the additional assign, but that should work.

    {assign var=groupIDs value= "1"|explode} {if $__wcf->getUser()->getGroupIDs()|in_array:$groupIDs}You're seeing this because you're a member of a particular usergroup{/if}

    Any idea how I would add an "else" statement in there. Because ideally you want X displayed if they are in group Y, but else they should see Z.

  • Yes.

    By default, every page (or form) uses the lower case variant of it's name as template name, without the suffix "Page" or "Form" . The page is called UserOnlineListPage, so the corresponding template is as you rightly guessed userOnlineList.tpl.

    This holds true for any product of WoltLab and is strongly encouraged for 3rd party devs to adhere to, too, but technically it is possble to change the name of the template. But that is very rare.

    "A life is like a garden. Perfect moments can be had, but not preserved, except in memory. LLAP" — Leonard Nimoy

  • Code
    {if $condition}
    Yay!
    {else}
    Nope :(
    {/if}

    Yes, but using WCF built in code?

    That's what I've not had time to learn... (Will not have free time until summer... Then I can dig down deep and stop with my endless questions)


    IF I understand the syntax correctly (unlikely)


    Code
    {assign var=groupIDs value= "1"|explode} {if $__wcf->getUser()->getGroupIDs()|in_array:$groupIDs}You're seeing this because you're a member of a particular usergroup{/if} 
    
    
    
    
    
    
    
    {assign var=groupIDs value= "4"|explode} {else $__wcf->getUser()->getGroupIDs()|in_array:$groupIDs}You're seeing this because you're a member of a particular usergroup{/else}
  • Yes, but using WCF built in code?

    That IS WCF built-in code.


    No, you got the syntax slightly off by closing the if-block prematurely. Putting it together you'd get:

    Code
    {assign var=groupIDs value= "1"|explode}
    {if $__wcf->getUser()->getGroupIDs()|in_array:$groupIDs}
    You're seeing this because you're a member of a particular usergroup
    {else}
    Nope :(
    {/if}


    You only need to assign once to fetch the values, there is no point in repeating it.

    "A life is like a garden. Perfect moments can be had, but not preserved, except in memory. LLAP" — Leonard Nimoy

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!