Results 1 to 34 of 34

Thread: Hide one or more content elements in the list (Articles)

  1. #1
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Hide one or more content elements in the list (Articles)

    In this time, it's possible to hide all the fields from a content element with the user group permissions but the content element is still available in the list. The best for the user would be to simply hide a content element and not only the fields.

    For example, with a checkbox in the user group permissions (Allowed content elements.
    http://dev.contao.org/issues/2870#change-10015

    how to do this?
    maybe in DCA? how hide content element by id for example
    sorry for my english

  2. #2
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Hide one or more content elements in the list (Articles)

    This may be a way ..... from here http://www.contao.org/custom-configurations.html

    Code:
    // Allow only admins to use include content elements
    if (!$this->User->isAdmin)
     { unset($GLOBALS['TL_CTE']['includes']); }
    so in dcaconfig.php
    if (such and such)
    {
    unset(such and such);
    }

  3. #3
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    :D

    if (user->ramjet)
    {
    unset(article_id->1&element_id->5);
    }

    I do not know how to do it.
    sorry for my english

  4. #4
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Hide one or more content elements in the list (Articles)

    The ce-access extension does exactly this.

    It's something I use on literally every site we do. I think it should be part of the core.

    http://www.contao.org/extension-list/vi ... 59.en.html
    Brian

  5. #5
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    ce-access hide operation button (delete cut etc) and element type but not the element itself
    and how hide content element by id?
    for example

    element type Text (id7)
    Text: Bla bla bla

    how hide it from other user in BE?
    sorry for my english

  6. #6
    Community-Moderator xchs's Avatar
    Join Date
    06-19-09.
    Posts
    1,287

    Default Re: Hide one or more content elements in the list (Articles)

    Version 1.1.1 of [ce-access] hides the specified CEs from the select field: http://www.contao.org/extension-list/vi ... 19.en.html

    Since version 1.1.2 Andreas has changed this, because according to him this was an error: http://www.contao-community.de/showthre ... aktivieren
    Contao Community Moderator
    → Support options

  7. #7
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    Thank you. better but not quite

    Code:
        $GLOBALS['TL_DCA']['tl_table']['list']['sorting']['filter'] = array
        (
            array('author_id=?', $this->User->id)
        );
    maybe that but
    if i change tl_table on tl_content - error

    there is no ['filter']
    sorry for my english

  8. #8
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Hide one or more content elements in the list (Articles)

    I see what you mean now -- actually hide the display and not the ability to add a new one.

    This seems to be a general philosophy in Contao that I have to admit I disagree with.

    I'd be interested in knowing the solution to this as well.
    Brian

  9. #9
    User
    Join Date
    06-29-09.
    Posts
    271

    Default Re: Hide one or more content elements in the list (Articles)

    Medianomaly, can you clarify that? I use the ce-access all the time but do not understand where the filter ties into the whole. ops:

  10. #10
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Hide one or more content elements in the list (Articles)

    It doesn't. I thought the question was about the select list when you make a new CE.

    He's talking about actually not showing content elements when you select an article in the BE. CE-Access used to do this as well, but now it displays them but grays out the icons to edit them.

    I disagree with how Contao handles things that users don't have permission to use. Throughout the backend, If you don't give a user permission to do something, they still see the element, icon/button, etc., but it will be grayed out and not clickable.

    This leads to our customers either being confused as to why they see something they can't click, or get mad that we are locking them out of something. It would be much cleaner and less confusing if they were just hidden all together.
    Brian

  11. #11
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    Code:
    $GLOBALS['TL_DCA']['tl_content']['list']['sorting']['filter'] = array
    (
      array('type=?', 'text')
    );
    it show only text element :!:

    how add more elements? for example module

    Code:
    array('type=?', 'text') $ array('type=?', 'module')
    OR

    Code:
    $GLOBALS['TL_DCA']['tl_content']['list']['sorting']['filter'] = array
      (
        array('protected=?', '')
    	
    );
    if Protect element- yes , then it this element is not visible 8-)

    Code:
       $GLOBALS['TL_DCA']['tl_content']['list']['sorting']['filter'] = array
      (
        array('guests=?', '')
    	
    );
    if Show to guests only- yes , then it this element is not visible 8-)
    sorry for my english

  12. #12
    User
    Join Date
    06-29-09.
    Posts
    271

    Default Re: Hide one or more content elements in the list (Articles)

    Quote Originally Posted by Medianomaly
    It doesn't. I thought the question was about the select list when you make a new CE.

    He's talking about actually not showing content elements when you select an article in the BE. CE-Access used to do this as well, but now it displays them but grays out the icons to edit them.

    I disagree with how Contao handles things that users don't have permission to use. Throughout the backend, If you don't give a user permission to do something, they still see the element, icon/button, etc., but it will be grayed out and not clickable.

    This leads to our customers either being confused as to why they see something they can't click, or get mad that we are locking them out of something. It would be much cleaner and less confusing if they were just hidden all together.
    What if they want to re-order items and have the rights to move other content elements on the same page. OR wouldn't users be able to change any.

    You could make your own theme and make the icon transparent?

  13. #13
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    WOW

    <ul id="ul_30" class="sortable">
    <li id="li_81">
    30 it id article
    81 it id element

    .ul_30 .li_81 {display:none;}

    but how ? :D
    sorry for my english

  14. #14
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Hide one or more content elements in the list (Articles)

    just guessing
    array('id != ?', 81'')

  15. #15
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    yes
    but only id 81 be show

    and unset not work

    stop if =! then 81 only hide

    and 82 85 etc?
    sorry for my english

  16. #16
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Hide one or more content elements in the list (Articles)

    sorry, I left an extra " in the code above ops:

    Code:
    if( !$this->User->isAdmin )
    {
    	$GLOBALS['TL_DCA']['tl_content']['list']['sorting']['filter'] = array
    	(
    		array('id != ?', 81)
       
    	);
    }
    This works in dcaconfig.php(tested).
    So if the user is NOT an admin, he will see all content elements EXCEPT 81

    You could say "if the users id IS 6" or "if the users username IS NOT ramjet" as below

    Code:
    if($this->User->id == 6)
    if($this->User->username != 'ramjet')
    array('id != ?', 81) will exclude 81
    or array('id = ?', 81) will include 81 only

    I don't know how you would hide more than one content element, as the filter doesn't appear to process arrays.

  17. #17
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    Code:
    if (!$this->User->isAdmin)
      {
        $GLOBALS['TL_DCA']['tl_content']['list']['sorting']['filter'] = array
          (
            array('type != ?', 'html')
          );
      };
    :roll:
    sorry for my english

  18. #18
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    if($this->UserGroup->id == 6)

    I can write so?
    sorry for my english

  19. #19
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Hide one or more content elements in the list (Articles)

    No.
    UserGroup is not a class file. User is.
    Also the groups are stored as a serialized array, so its a bit harder as the data needs to be deserialized and the array searched first.

    So (untested)

    Code:
    $groups = deserialize($this->User->groups);
    if(in_array('6',$groups))
    {
       $GLOBALS['TL_DCA']['tl_content']['list']['sorting']['filter'] = array
       (
          array('id != ?', 81)
       );
    
    }

  20. #20
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    it works!
    ramjet, thank you !
    sorry for my english

  21. #21
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Hide one or more content elements in the list (Articles)

    no worries :D

  22. #22
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    hi, ramjet!

    Whether it is possible?
    DCA
    if article id=4 then
    unset($GLOBALS['TL_DCA']['tl_content']['list']['operations']['delete']);

    :D
    sorry for my english

  23. #23
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    Code:
    if (!$this->article->id == 30)
    {
    unset($GLOBALS['TL_DCA']['tl_content']['list']['operations']['delete']);
    };
    unset it is executed in all articles
    sorry for my english

  24. #24
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Hide one or more content elements in the list (Articles)

    Because there is no $this->article->id, so all rows fulfil the condition ("its not 30").

    The unset part is fine.
    The problem I think is there is no access to the individual records, just the Container (DCA = Data Container Array)
    You could try adding a button_callback to the delete button ,

    Code:
    $GLOBALS['TL_DCA']['tl_content']['list']['operations']['delete'] = array('button_callback'  => array('myClass', 'changeButton'));

    but you'd have to write a class and method for it to call (which I think requires you making a module)

    You could use the parent id of the elements (which is the id of the article)
    The method would look something like this

    Code:
    	
    public function changeButton($row, $href, $label, $title, $icon, $attributes)
    {
       if($row['pid'] == 4)
       {
        $icon = '[img]THE_GREYED_OUT_DELETE_ICON.gif[/img]';
       }
    		
     return $icon;
    }

    OR you could just tell your User "make sure you don't delete it" and show him the Undo area in case he does :D

  25. #25
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    Quote Originally Posted by ramjet
    OR you could just tell your User "make sure you don't delete it" and show him the Undo area in case he does :D
    I think it is better :D
    sorry for my english

  26. #26
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Hide one or more content elements in the list (Articles)

    Me too :D :D

  27. #27
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    People!

    How add css in BE
    like that

    Code:
    if ({{env::referer}} == 'site.com/contao/main.php')
    {
    $GLOBALS['TL_CSS'][] = 'path/to/stylesheet.css';
    }
    and why if (!$this->User->isAdmin) not work for this
    sorry for my english

  28. #28
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Hide one or more content elements in the list (Articles)

    You're better off to start a new thread, as this has nothing to do with "Hide one or more content elements in the list", and so someone who might be able to answer you won't read it.
    As for me - Dunno :cry:

    ps: it would help a bit if you were to explain more about where you are trying to use this

  29. #29
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    sorry for my english

  30. #30
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Hide one or more content elements in the list (Articles)

    Quote Originally Posted by Energetik
    People!
    Code:
    if ({{env::referer}} == 'site.com/contao/main.php')...
    Try:
    Code:
    if( TL_MODE == 'BE' )...
    Quote Originally Posted by Energetik
    and why if (!$this->User->isAdmin) not work for this
    Depending on where you are putting that you might need the following:
    Code:
    $this->import('User');
    If you start that new thread I can post this there too...
    Brian

  31. #31
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    Medianomaly
    and if
    if ({{env::referer}} == 'site.com/contao/main.php')
    if ({{env::referer}} == 'site.com/contao/blabla.php')
    if ({{env::referer}} == 'site.com/contao/article/bla.php')
    etc..
    How then?
    sorry for my english

  32. #32
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Hide one or more content elements in the list (Articles)

    sorry for my english

  33. #33
    New user
    Join Date
    09-28-10.
    Posts
    4

    Ausrufezeichen

    Hello,

    I know that this topic is very old, but I search the way to do exactly what Energetik want to do.

    Quote Originally Posted by Energetik View Post
    :D

    if (user->ramjet)
    {
    unset(article_id->1&element_id->5);
    }

    I do not know how to do it.
    Do you have any solution to hide element of article for users ? I also tried ce-access but that's not the solution.
    thanks in advance for your reply.

    Vincent

  34. #34
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    It's somehow unclear to me what Energetik tries to achieve so far. Maybe it's better to start a new thread and describe in a few clear words what you want to achieve and why.

    If you want a special CSS in BE only for non-admin users of a special group, you can do it this way in system/config/initconfig.php.
    PHP Code:
    <?php

    /**
     * Here you can add custom initialization routines that are executed
     * on every back end and front end request.
     */

    /** Some extra BE CSS and JS */
    if(TL_MODE == 'BE' && \BackendUser::getInstance()->isMemberOf(2))
    {
      
    $GLOBALS['TL_CSS'][] = 'files/css/_my_editor_be.css';
    }
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •