Jump to content

Meddysong

Clients
  • Posts

    2,172
  • Joined

  • Last visited

  • Days Won

    3

Reputation Activity

  1. Like
    Meddysong reacted to opentype in Theme Tip: Dynamic(ish) forum feeds inside Pages databases   
    Try checking the language first in a PHP IF query {{ if …}} and put your codes as result in a variable, e.g. {{$currentLanguage = "eo";}}. Then you can call the block just like in Rikki’s example, e.g. {block="course-attendance-{$currentLanguage}"}
  2. Like
    Meddysong reacted to Rikki in Theme Tip: Using Pages blocks anywhere   
    @Meddysong I'm afraid the answer isn't very exciting! Since we only have a handful of pages in the feature tour and they don't change much, if ever, they're simply hand-coded as part of the header of each page:
    <div class='col-sm-2 col-sm-push-8 ipsType_right sFeatureTour_next'> <a href='/features/engagement' class='ipsButton ipsButton_link ipsButton_large'><span></span>Engagement   <i class='fa fa-user-plus'></i></a> </div> It would certainly be possible to make this dynamic using a block though, which would be better suited if you had lots of pages that regularly changed (or you needed to reorder them).
    The way I'd approach that is to use a PHP array to store the correct order of my pages, and then use array positions to figure out what the next/previous page should be. Something like this (off the top of my head and subject to errors/bad logic!):
    {{$myPages = array( 'features/page1' => "Page One", 'features/page2' => "Page Two", 'features/page3' => "Page Three"); }} {{$pageNames = array_keys( $myPages ); }} {{$curPageIndex = array_search( \IPS\Request::i()->page, $pageNames ); }} <ul> <li> {{if $curPageIndex !== FALSE && isset( $pageNames[ $curPageIndex - 1 ] )}} Prev: <a href='{$pageNames[ $curPageIndex - 1 ]}'>{$myPages[ $pageNames[ $curPageIndex - 1 ] ]}</a> {{endif}} </li> <li> {{if $curPageIndex !== FALSE && isset( $pageNames[ $curPageIndex + 1 ] )}} Next: <a href='{$pageNames[ $curPageIndex + 1 ]}'>{$myPages[ $pageNames[ $curPageIndex + 1 ] ]}</a> {{endif}} </li> </ul> Here I'm creating an array that represents the filenames, page titles, and they're in the order I want them to show. If I wanted to change the page order, or add new pages, I'd just change the $myPages array.
    I'd build this as a block, and drop it into all the pages that should show the menu  
  3. Like
    Meddysong reacted to Martin A. in Theme Tip: Use HTML logic to display content to specific groups   
    You can also used the built-in inGroup method to check if a member is in a certain group, instead of the in_array option.
    {{if \IPS\Member::loggedIn()->inGroup( array( 2, 4, 6 ) )}} This content only shows to members in groups with the ID 2, 4 or 6. {{endif}}  
×
×
  • Create New...