-
Hide one or more content elements in the list (Articles)
Quote:
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
-
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);
}
-
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.
-
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
-
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?
-
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
-
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']
-
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.
-
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. :oops:
-
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.
-
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-)
-
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?
-
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
-
Re: Hide one or more content elements in the list (Articles)
just guessing
array('id != ?', 81'')
-
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?
-
Re: Hide one or more content elements in the list (Articles)
sorry, I left an extra " in the code above :oops:
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.
-
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:
-
Re: Hide one or more content elements in the list (Articles)
if($this->UserGroup->id == 6)
I can write so?
-
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)
);
}
-
Re: Hide one or more content elements in the list (Articles)
it works! :)
ramjet, thank you !
-
Re: Hide one or more content elements in the list (Articles)
-
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
-
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 :(
-
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
-
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
-
Re: Hide one or more content elements in the list (Articles)
-
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
-
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
-
Re: Hide one or more content elements in the list (Articles)
-
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...
-
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?
-
Re: Hide one or more content elements in the list (Articles)
-
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
: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
-
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';
}