Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 1046 Vote(s) - 3.57 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to set different default attribute values for different user groups in the Composer interface for Concrete5?

#1
*Hi all, I think this might be or might not be a programming question. But I've tried to ask this question on concrete5 forum with no luck. Hope someone could give me a clue here..*

**Is there any way I could set different default values for attributes in composer for each user group?**

Let me explain my question in detail. My client has around 60 organization unit (each unit will have their own user group). For every unit, they want to have their own page listing. Containing exclusively all the article which is posted by the unit member. Beside of that, all post from organization unit should also be a aggregated on a subcategory of the global news category. So I construct the content structure to be like this

ORGANIZATIONAL UNIT DIRECTORY [page type]

- unit 1's articles
- unit 2's articles
- unit 3's articles
- ...

NEWS [page type]

- organization unit info [contains aggregated page listing from all unit]
- ..other news subcategory..
- ..other news subcategory..
- ..other news subcategory..

For the above content structure, I set the "NEWS" top category and "ORGANIZATIONAL UNIT DIRECTORY" as page_type, and create an attribute for the news subcategory (I named it "news_location"). And create one more attribute to determine the unit (I named it "unit").

Now, My question is, how can I pre-set the attribute "news_location" and "unit" on composer for a particular user group. For example, for member of "unit 1". I want them to have a unique composer which have the attribute "news_location" pre-set to "organization unit info" and attribute "unit" pre-set to "unit 1". And he can't change those attribute, so that we could make sure they will only post a new article on the appropriate place/category.

I have been fidling with the concrete5 CMS but can't find any way to do this. Should I dig the code and make my own module for this?

That's it... looking forward for the solution. I'm sorry if my question is too convoluted :p
Reply

#2
There is definitely no built-in feature that lets you set different default attribute values in Composer for different user groups (in fact, I don't even think it's possible to set *any* default values for attributes -- even if it were the same default value for all users).

You could override the core `CollectionType` class -- in the `getComposerContentItems` method you could write some code to check the current page type, check each attribute Key, and for certain attributes put in default values depending on the current user's group.

But the really hard part is actually setting values on attributes. There is no elegant way to do so in Concrete5 -- attribute values are always tied to the object that the attribute is assigned to (for example, a page, a file, or a user). I have tried in the past to arbitrarily set any default value on an attribute but there is no easy way to do so. (It's not too hard for simple attribute types like textbox and checkbox... but for more complex things like DateTime and Select types, it's so complex that I didn't even bother trying to figure it out).

What you might want to try instead is creating your own attribute type, and then in the attribute type itself you figure out how to set default values (if no value already exists) based on the user group. Here is some basic code I have that demonstrates the bare minimum of what's required for your own attribute types:

[To see links please register here]


Also check the C5 documentation for more detailed (but also messier and harder to understand) explanations and sample code:

[To see links please register here]


Best of luck!
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through