We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27889
    • 415 Posts
    I’ve made a catalogue solution to present articles, products or whatever you want.
    It is in beta version, can you send me feedback ? Here is the demo, the codes follow.


    Attachment: A screenshot of the edit mode.

    What it does:

    • All the "fields" for articles are tv or document fields : pagetitle, longtitle, description.
    • Include maxiGallery snippet, you can add a gallery (with lightbox smiley )for each article and manage it (dowload, sort, add, remove), see MaxiGallery snippet
    • Full frontend edit after manager loggin, edit fields, add article, delete article, manage images.
    • List of all articles with one thumb image for it (if set)
    The files:

    • A snippet to add an article
    • A snippet to delete an article (and its gallery)
    • A snippet to present a list of articles with one thumb
    • A chunk that is a template to display full articles informations
    • A plugin to redirect editor to the frontend with QuickEdit rights.

    Todo:

    • Add comment to the code
    • write a good readme
    • test and more smiley

    Here it is:

    Each product is a document under a folder (utilised for the articles list) in the documents tree
    The ListArticles page (the root folder for article):
    It contains only a call to the [[ArticlesList]] snippet:
    The database is searched to retrieve all articles, and then for each one we search if it has an image.
    The content is displayed in a table
    Each image (or non-image text) is linked to the article’s page.

    The article Page:
    It contains only a call to a chunk that is a template to diplay each article on one page:
    {{ArticlesTpl}}
    This chunk contains the fields to display the articles in a [*#NameFields*] so they can be edited with quickedit.
    Somes are TV, other are page propriety (pagetitle, longtitle, description)
    There is a call to maxigallery to display the gallery.
    There is a link to return to the list of all the articles.
    The call to [[RemoveArticle]] and [[AddArticle]] are used to add and remove an article.

    The [[AddArticle]] snippet:

    The [[RemoveArticle]] snippet:
    And the redirect snippet to disallow manager access to non-Admin users:
    You must add this new event in the "system_eventnames" table (this is the sql code):
    INSERT INTO `modx_system_eventnames`  ( `id` , `name` ,`service` , `groupname` )
    VALUES (  '93','onBeforeManagerPageInit', '2','');


    Added these lines to the /manager/index.php at line 184, just before [tt]// first we check to see if this is a frameset request[/tt] to invoke the new event.
    ( I don’t know what to do with the parameter :[tt]array("action" => $action)[/tt])
    // ****HACK**** New event added:
    $modx->invokeEvent("OnBeforeManagerPageInit",array("action" => $action));
    //***********************************************************************

    In the Redirect plugin with the "Manager Access Events" "OnBeforeManagerPageInit" and "OnManagerLogin" checked.
    if  ($_SESSION['mgrPermissions']['id']!='1'){$modx->sendRedirect($modx->makeurl($modx->config['site_start']));}
    




    PS:I’m not a coder and haven’t an high skill in english (isn’t it ?)

      MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
      MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
      • 6726
      • 7,075 Posts
      Very interresting, so far I have managed catalogues with... Ditto and TVs.
      I guess it would be possible to use MaxiGallery on top of that, but never needed that so far.

      I am curious to see your work !
      I don’t know if the redirect part will be possible without hacking the core though...

      I’ll be following progress and of course I am willing to help with the beta testing smiley





        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 25663 MODX Staff
        • 12,272 Posts
        $modx->sendRedirect, I think David.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 6726
          • 7,075 Posts
          Oops, I stand corrected !
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l'outil id
            • 25663 MODX Staff
            • 12,272 Posts
            Hello. Looks good and I don’t see any areas where it’s not working as I would expect it to work.

            What are you using to publish and edit articles from the front end?

            Keep up the great work. smiley
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 25663 MODX Staff
              • 12,272 Posts
              In the Manger Users tab in 0.9.2.1, the first option under user settings will redirect them to a specified page. It does not apply pervasively to all users though, or by role. Your plugin in that regard is really a wonderful addition. I suppose you could extend it to redirect them to the front end page any time they try to access a manager page.

              In the Quick Edit module, when you edit the configuration, there is an option to turn off the Manager link as well.
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 27889
                • 415 Posts
                DavidM thanks for your help, I think I need some good MODxer smiley

                What are you using to publish and edit articles from the front end?
                Each article are a document, to edit an article I use the cool QuickEdit for TV and page fields (pagetitle, description are in place why not use ? smiley).
                To publish the list articles I make a call with the dbapi (It was more difficult to find a exemple, than to code:))
                to find the thumb image.
                The Article page is a simple lisr of TV and a call to the Maxigallery snippet.

                I hope it answer to your question. (I hope that I had understand you).

                  MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
                  MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Actually, wouldn’t that be "onBeforeManagerPageInit" ? Logically, "onManagerPageInit" happens on the event occurring (onclick, onmouseover, etc). So you should really create a new event, not hack or reposition the existing one.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 27889
                    • 415 Posts
                    Thanks for the info Susan. Here it is.

                    The new redirect plugin.


                    Added this new event in the "system_eventnames" table (this is the sql code):
                    INSERT INTO `modx_system_eventnames`  ( `id` , `name` ,`service` , `groupname` )
                    VALUES (  '93','onBeforeManagerPageInit', '2','');


                    Added these lines to the /manager/index.php at line 184, just before [tt]// first we check to see if this is a frameset request[/tt]
                    ( I don’t know what to do with the parameter :[tt]array("action" => $action)[/tt])
                    // ****HACK**** New event added:
                    $modx->invokeEvent("OnBeforeManagerPageInit",array("action" => $action));
                    //***********************************************************************

                    In my plugin:
                    [tt]if ($_SESSION[’mgrPermissions’][’id’]!=’1’){$modx->sendRedirect($modx->config[’site_start’]); }[/tt]
                    with the "Manager Access Events" "OnBeforeManagerPageInit" and "OnManagerLogin" checked.

                    But after the redirect of an non-administrator user, the url is: [tt]
                    |-|ttp://localhost:85/modx/manager/processors/2[/tt] (2 is the id of my redirect page:[’site_start’])


                    Solved:

                    if ($_SESSION[’mgrPermissions’][’id’]!=’1’){$modx->sendRedirect($modx->makeurl($modx->config[’site_start’]));}


                    Is this the good method ?

                    ps: MODx nominate ok
                      MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
                      MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
                      • 25663 MODX Staff
                      • 12,272 Posts
                      Can someone tell me what that array("action"=>$action) is used for. The reason I ask, is that other events are invoked with a $this and no action parameter, like:

                      $this->invokeEvent(’OnPageNotFound’); (near line 97)


                      Also, wouldn’t it make sense to insert this event call in the portion where it checks for the presence of a Manager Login such as:
                      <?php
                          // store base_url and base_path inside config array
                          $this->config['base_url'] = $base_url;
                          $this->config['base_path'] = $base_path;
                          $this->config['site_url'] = $site_url;
                      
                          // load user setting if user is logged in
                          if($id=$this->getLoginUserID()){
                            $usrType = $this->getLoginUserType();
                            if (isset($usrType) && $usrType!='web') $usrType = 'mgr';
                      
                            if $usrType == 'mgr' {
                                // invoke the OnBeforeManagerInit event
                                $this->invokeEvent("OnBeforeManagerInit"); 
                            }
                      
                            if(isset($_SESSION[$usrType.'UsrConfigSet'])) {
                              $usrSettings = &$_SESSION[$usrType.'UsrConfigSet'];
                            }
                      ?>


                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me