Fork me on GitHub
Current releases are 2.1.5 (31 Oct 2014) and 2.0.18.13 (5 Aug 2014)

Ready for 2.1? Find out if your plugins are compatible. 2.0 will no longer be updated after Dec 2014.

Feature requests

bobthemanbobtheman
edited September 2010 in Vanilla 2.0 Help
This discussion is related to the Custom Pages addon.
some features i would love to see in this app

ability to edit pages from admin dashboard
wysiwyg editor
private pages, password protected
media upload ability
comment system, could use the discussion application for this

Comments

  • I'd love to be able to protect certain pages by member role... Is there something that I can add to my page to get vanilla to do this?

    My addons: NillaBlog | Vanoogle

  • ddumontddumont ✭✭
    edited November 2010
    I'd love to be able to protect certain pages by member role... Is there something that I can add to my page to get vanilla to do this?
    I'd love for a way to do this more automatically, but here's how I ended up doing it.
    in my custom page:

    $perm_manage = Gdn::Session()->CheckPermission('Plugins.CustomPageFood.Manage');
    $perm_view = Gdn::Session()->CheckPermission('Plugins.CustomPageFood.View');
    if (!($perm_view || $perm_manage)) {
    exit();
    }


    And in the default.php for the CustomPages plugin I added this:
    $PluginInfo['CustomPages'] = array(
    'Name' => 'Custom Pages',
    'Description' => 'A plugin that lets you add custom pages...',
    'Version' => '1',
    // I added the line below:
    'RegisterPermissions' => array(
    'Plugins.CustomPageFood.Manage',
    'Plugins.CustomPageFood.View'
    ),




    My addons: NillaBlog | Vanoogle

  • A revision feature would be swaggedy!
  • Revision feature for what exactly, @yusf?
  • @hyphy
    A functionality for version rollback and such. A wiki more or less. :)
  • PamelaPamela ✭✭
    edited June 2012

    ddumont said: I'd love to be able to protect certain pages by member role... Is there something that I can add to my page to get vanilla to do this?

    I'd love for a way to do this more automatically, but here's how I ended up doing it. in my custom page:

    $perm_manage = Gdn::Session()->CheckPermission('Plugins.CustomPageFood.Manage'); $perm_view = Gdn::Session()->CheckPermission('Plugins.CustomPageFood.View'); if (!($perm_view || $perm_manage)) { exit(); }

    And in the default.php for the CustomPages plugin I added this: $PluginInfo['CustomPages'] = array( 'Name' => 'Custom Pages', 'Description' => 'A plugin that lets you add custom pages...', 'Version' => '1', // I added the line below: 'RegisterPermissions' => array( 'Plugins.CustomPageFood.Manage', 'Plugins.CustomPageFood.View' ),

    Many thanks to share this tip but is it the best way? for do it :) now... with v2.0.18.4

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP
    edited June 2012

    the above should work in 2.18.0.4. Can't answer if it is the best way.

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

    Pamela
  • PamelaPamela ✭✭

    peregrine said: the above should work in 2.18.0.4. Can't answer if it is the best way.

    Ok, thank you :) so, I will try...

  • SheilaSheila ✭✭

    Hi!

    Could I get more detailed (n00b proof) info, how to add code that dumond posted?

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP

    what don't you understand?

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

    Sheila
  • SheilaSheila ✭✭

    The exact lines where to add the code, and if I should wrap it within php -function and if, then how to do it. Sorry, I'm really bad with these. Willing to learn but..

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP
    edited July 2012

    I haven't tested the custom pages aspect - but it does put permissions in your dashboard.

    he's saying to the CustomPages plugin - default.php

    $PluginInfo['CustomPages'] = array(
       'Name' => 'Custom Pages',
       'Description' => 'A plugin that lets you add custom pages. You need to add them to the "pages" folder of this plugin.',
       'Version' => '1',
       'Author' => "Mark O'Sullivan",
       'AuthorEmail' => 'mark@vanillaforums.com',
       'AuthorUrl' => 'http://vanillaforums.com'
    );
    

    to this... (this should give you manage and view options for CustomPageFood in the dashboard permissions.

    $PluginInfo['CustomPages'] = array(
       'Name' => 'Custom Pages',
       'Description' => 'A plugin that lets you add custom pages. You need to add them to the "pages" folder of this plugin.',
       'Version' => '1',
      'RegisterPermissions' =>array('Plugins.CustomPageFood.Manage','Plugins.CustomPageFood.View'),
       'Author' => "Mark O'Sullivan",
       'AuthorEmail' => 'mark@vanillaforums.com',
       'AuthorUrl' => 'http://vanillaforums.com'
    );
    

    and add this to your custom page food.

        $perm_manage = Gdn::Session()->CheckPermission('Plugins.CustomPageFood.Manage');
        $perm_view = Gdn::Session()->CheckPermission('Plugins.CustomPageFood.View');
        if (!($perm_view || $perm_manage)) {
        exit();
        }
    

    obviously if food is not your custom page change it accordingly.

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

  • SheilaSheila ✭✭
    edited July 2012

    Okay, thanks. Seems like I did it right then in a first place. But no new options in the admin and code is visible on the public side.

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP
    edited July 2012

    did you wrap it in php tags?

    <?php 
     $perm_manage=Gdn::Session()->CheckPermission('Plugins.CustomPageFood.Manage');
    
     $perm_view = Gdn::Session()->CheckPermission('Plugins.CustomPageFood.View');
    
      if (!($perm_view || $perm_manage)) { exit();  }
        ?>
    

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP
    edited July 2012

    the options for permissions will show up in each role towards the bottom just before the default category permissions.

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

  • SheilaSheila ✭✭
    edited July 2012

    peregrine said: did you wrap it in php tags?

    Of course not! ;)

    To be honest, I kept just staring the part <?php if (!defined('APPLICATION')) exit(); ?> and wondering, were exactly is the place to add this other function.

    At least something happened since there's a WSOD now. No new permissions in the admin thou.

    This is what I used: <?php $perm_manage=Gdn::Session()->CheckPermission('Plugins.CustomPageFaqs.Manage'); $perm_view = Gdn::Session()->CheckPermission('Plugins.CustomPageFaqs.View'); ?>

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP

    This is what I used: <?php > $perm_manage=Gdn::Session()->CheckPermission('Plugins.CustomPageFaqs.Manage'); > $perm_view = Gdn::Session()->CheckPermission('Plugins.CustomPageFaqs.View'); > ?>

    What exactly is you goal. to only have people logged in, able to view it?

    in that case you could just check for (and forget about the mods to plugin).

    $Session = Gdn::Session();
            // this tests to see is user is logged in
            if ($Session->IsValid()) {
                  // do the faq stuff
    
             } else {
    
                // display you don't have permission to view.
    

    }

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

  • SheilaSheila ✭✭
    edited July 2012

    peregrine said: What exactly is you goal. to only have people logged in, able to view it?

    Yes, just to set that page visible for logged in members only. Most ideal would be, if menu link also is hidden. I think it's often just more user friendly to hide things completely than give those 'You don't have permission to...' -messages.

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP

    How did you add it to the menu in the first place?

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

  • SheilaSheila ✭✭

    It is included in Air theme default.master.php, $this->Menu->AddLink('FAQS', T('FAQS'), '/faqs');

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP
    edited July 2012
    put this in the  default.master.php
    
       if (Gdn::$Session->IsValid()) {
                $this->Menu->AddLink('FAQS', T('FAQS'), '/faqs');
                }
    
    
    put this in the application
    
    if  (!Gdn::Session()->IsValid()) {
                 exit();  
                }
    

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

    Sheila
  • SheilaSheila ✭✭

    peregrine said: put this in the default.master.php
    if (Gdn::$Session->IsValid()) { $this->Menu->AddLink('FAQS', T('FAQS'), '/faqs'); }

    I get Fatal error: Access to undeclared static property: Gdn::$Session in /themes/default/views/default.master.php on line 32

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP
    edited July 2012

    try this then

    $Session = Gdn::Session();
    
    if ($Session->IsValid()) {
       $this->Menu->AddLink('FAQS', T('FAQS'), '/faqs'); 
     }
    

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

    Sheila
  • SheilaSheila ✭✭
    edited July 2012

    ^ Just superb! That did it. Thank you once again :)

    That hided also other custom page link that is listed after 'Faq' and which I want guests to see since it's a contact page, but I solved that with adding manage and view options to contact-page.

    I could have naturally moved contact link before faq if it was any other page, but contact just shoudn't be in the middle of main menu unless that is most important page of the site.

    peregrine said: the options for permissions will show up in each role towards the bottom just before the default category permissions.

    I found an answer to this, why I did not see any new options in role management. In order to changes take an effect, plugin needs to be turned off and back on.

Sign In or Register to comment.