sharing custom attributes between blocks
Permalink
i'm new to c5 and i'm trying to figure out if it is going to meet our needs. currently with our cms you can link modules together. so a basic example might be that you have a country module, then products and case studies can be assigned to a country from their respective modules.
from what i've read the way to get close to this is to make a products block then make a custom country attribute - is that correct? if so is it possible for my case studies block to have the same country attribute as the products, i.e. the country values are common to both blocks?
thanks.
from what i've read the way to get close to this is to make a products block then make a custom country attribute - is that correct? if so is it possible for my case studies block to have the same country attribute as the products, i.e. the country values are common to both blocks?
thanks.
thanks a lot for the detailed answer. good to hear that i should be able to achieve it with c5.
storing data in the page is really interesting and not something i'd picked up on while viewing the videos and posts i've seen so far.
so to extend my first example slightly if i have one page that has case studies and another that has products, i'd like it so that each could share the same country table - so the data is consistent across the site and can be brought together later. e.g. we could make a search page that allows you to search by country and list products and case studies for that country. does that make sense? how would you approach this in c5?
sorry if my c5 terminology is all mixed up.
storing data in the page is really interesting and not something i'd picked up on while viewing the videos and posts i've seen so far.
so to extend my first example slightly if i have one page that has case studies and another that has products, i'd like it so that each could share the same country table - so the data is consistent across the site and can be brought together later. e.g. we could make a search page that allows you to search by country and list products and case studies for that country. does that make sense? how would you approach this in c5?
sorry if my c5 terminology is all mixed up.
I think you're getting the idea. In C5, you would use a "custom attribute" for the country. A custom attribute is a piece of data that can be assigned to a particular page (which is pretty much what @Mainio said above). You can create these very easily by going to Dashboard -> Pages and Themes -> Attributes. For a dropdown list of countries, you'd want the "Select" type (pick that from the menu under "Add Page Attribute"). When entering the attribute info, check both boxes under the "Searchable" section to tie it into site search results.
One tricky thing here is that C5 already includes an attribute that contains all the countries -- but unfortunately it's wrapped up inside the "Address" attribute which is for Users (as opposed to pages)... so I don't know how familiar with programming you are if you want to try to pull this attribute out of the more complex "address" attribute (seehttp://www.concrete5.org/documentation/how-tos/developers/create-a-... ), or if you only have a few different countries to choose from and so it's okay to enter them manually.
If you've got some time on your hands, here are a few really long-winded posts I've written about how the C5 way of thinking differs from other CMS's:
http://www.concrete5.org/community/forums/customizing_c5/using-a-sp...
http://www.concrete5.org/community/forums/customizing_c5/will-concr...
http://www.concrete5.org/community/forums/customizing_c5/beginneran...
Good luck!
One tricky thing here is that C5 already includes an attribute that contains all the countries -- but unfortunately it's wrapped up inside the "Address" attribute which is for Users (as opposed to pages)... so I don't know how familiar with programming you are if you want to try to pull this attribute out of the more complex "address" attribute (seehttp://www.concrete5.org/documentation/how-tos/developers/create-a-... ), or if you only have a few different countries to choose from and so it's okay to enter them manually.
If you've got some time on your hands, here are a few really long-winded posts I've written about how the C5 way of thinking differs from other CMS's:
http://www.concrete5.org/community/forums/customizing_c5/using-a-sp...
http://www.concrete5.org/community/forums/customizing_c5/will-concr...
http://www.concrete5.org/community/forums/customizing_c5/beginneran...
Good luck!
Both of the very intelligent folks here(@Mainio and @jordanlev) are hinting at a big concept that took me a little while to warm up to. At first when you look at the "block" stuff you generally start thinking about "modules". The thing with Concrete5 is that it is typically more "page" based than "block" based it seems.
I kind of think of pages as the main object and blocks as display modules or interaction modules of that object.
That said you can always just create a second table within a block's db.xml and share it between all of the same block types. Concrete5 uses adodb("half baked" active record and all). This still seems to be my habit instead of the more Concrete5-ish idiom of page based because the page based thing for data storage seems a little clunky to me. This could be because I'm running a 50 at a time cron job every ten minutes on a shared host to clean up 27,000 orphaned pages from a parent delete timeout for a client. But I digress. ;)
Either way, sorry we missed you. The only reason I'm here is cause of how awesome the community is and I'm sure we won't let it slide next time!
I kind of think of pages as the main object and blocks as display modules or interaction modules of that object.
That said you can always just create a second table within a block's db.xml and share it between all of the same block types. Concrete5 uses adodb("half baked" active record and all). This still seems to be my habit instead of the more Concrete5-ish idiom of page based because the page based thing for data storage seems a little clunky to me. This could be because I'm running a 50 at a time cron job every ten minutes on a shared host to clean up 27,000 orphaned pages from a parent delete timeout for a client. But I digress. ;)
Either way, sorry we missed you. The only reason I'm here is cause of how awesome the community is and I'm sure we won't let it slide next time!
@Mainio - "First of all, it's a bit shame to see that people who are new to concrete5 and might be becoming new users are quite often ignored on these forums."
--ouch I'm doing my best, I promise.
--ouch I'm doing my best, I promise.
No problem, it was a bit provocative actually to get some action here in the first place... :)
But overall, there isn't usually that many topics left un-answered but if I see one, usually the user has 0 karma and 1 posted message. This is just the feeling I'm getting...
But overall, there isn't usually that many topics left un-answered but if I see one, usually the user has 0 karma and 1 posted message. This is just the feeling I'm getting...
If you go to dashboard > sitewide settings > attributes, it shows a cross reference of what attributes are available for what objects within the system. ecommerce adds products and orders to the columns, and a few rows for new attributes for price etc.
What this shows is that in C5 you can:
- create new attribute types
- create new things that have attributes
- mix and match how they can be used
Some of these are easy to do, while others require code. Some make little sense (eg adding an order adjustment attribute to a user).
What this shows is that in C5 you can:
- create new attribute types
- create new things that have attributes
- mix and match how they can be used
Some of these are easy to do, while others require code. Some make little sense (eg adding an order adjustment attribute to a user).
thanks for all the help, i was thinking it was a bit slow at first, but you've definitely all turned it around now ;)
as a result i think i'm slowly getting there, sorry for being a bit dense. the pages stuff is really useful, all the beginners info focuses on blocks and the advantages of using them, but learning about the page structure and the concept (sites built of pages rather than database tables) is v.useful and helps tie the whole thing together.
i think i may have confused the issue with my example above as the country info is static so just needs to be plonked in the database somewhere, but what i am looking to do is to link one page with another page (hopefully i have the right terminology this time).
so imagine i have a few pages
1. client page
2. performance page
3. case study page
i would like to link performance and case studies to a client.
am i correct in thinking i can create a custom select attribute for the performance and case studies pages that contains a list of clients? then when i add new client pages they will appear in the attribute select list for case study and performance pages, so that later i could have a page that listed all the pages that apply to a client (client page, performance pages, case study pages)?
as a result i think i'm slowly getting there, sorry for being a bit dense. the pages stuff is really useful, all the beginners info focuses on blocks and the advantages of using them, but learning about the page structure and the concept (sites built of pages rather than database tables) is v.useful and helps tie the whole thing together.
i think i may have confused the issue with my example above as the country info is static so just needs to be plonked in the database somewhere, but what i am looking to do is to link one page with another page (hopefully i have the right terminology this time).
so imagine i have a few pages
1. client page
2. performance page
3. case study page
i would like to link performance and case studies to a client.
am i correct in thinking i can create a custom select attribute for the performance and case studies pages that contains a list of clients? then when i add new client pages they will appear in the attribute select list for case study and performance pages, so that later i could have a page that listed all the pages that apply to a client (client page, performance pages, case study pages)?
Yes, you could actually do that but in concrete5 context I would probably create in this situation client pages as their own directory and add subpages to each of the client pages:
- performance
- case study
However, I'm not quite sure what you're trying to do, so in some cases what you suggested might also be better, depending on the context.
Either way, if you want to create the custom select attribute, there's 0 lines of code you need to do, that can be accomplished through the dashboard. When using that attribute you just need to call one function for each of the "collections" (as concrete5 talks about page entities that contain blocks).
Here you have a bunch of page methods listed:
http://www.concrete5.org/documentation/developers/pages/overview...
The one you need here is:
where $akHandle is the "handle name" what you have used when creating that attribute (e.g. 'client_name').
- performance
- case study
However, I'm not quite sure what you're trying to do, so in some cases what you suggested might also be better, depending on the context.
Either way, if you want to create the custom select attribute, there's 0 lines of code you need to do, that can be accomplished through the dashboard. When using that attribute you just need to call one function for each of the "collections" (as concrete5 talks about page entities that contain blocks).
Here you have a bunch of page methods listed:
http://www.concrete5.org/documentation/developers/pages/overview...
The one you need here is:
$page->getAttribute($akHandle)
where $akHandle is the "handle name" what you have used when creating that attribute (e.g. 'client_name').
YES! that's awesome, thank you, and thanks to everyone who helped get this message into my little noob brain.
First of all, it's a bit shame to see that people who are new to concrete5 and might be becoming new users are quite often ignored on these forums. Hopefully the situation will get a bit better as the community grows.
This might also be related to the question in the first place, I think many people are not getting what you're asking specifically. However, I'll try to help although I'm not sure either if I'm answering you correctly.
>> currently with our cms you can link modules together. so a basic example might be that you have a country module, then products and case studies can be assigned to a country from their respective modules.
Well not sure whether you are coming from Drupal, Joomla! or whatever but at the basic level concrete5 does not work like that. It consists of re-usable blocks you can add to any page.
However, you can achieve shared attributes with Page attributes. Quite often what I've seen people doing with C5 is that they are using the pages as "shared data storage". This way they can share e.g. page-specific attributes with different blocks. For example, I think that almost all of the blog add-ons use the pages to store their articles and their other data (e.g. tags, short descriptions, author names, etc.). Also, to take another example of this way of thinking, if you want to add comments on your blog, you just add a new block "guestbook" to that page or create a single page to handle those blog pages.
Overall, I would say that there's not much (or anything) you really CAN'T do with concrete5, it just has a bit of different mindset than other CMSs. Personally for me as a developer, I would say that first it was quite hard to get into when I came from other CMS systems to concrete5. However, now I couldn't live without it!
>> if so is it possible for my case studies block to have the same country attribute as the products
These are quite case-specific things but for a short answer I'd say yes. There's only like a million way to do that. In this case I would use the eCommerce add-on (as you talked about products), add a "country" attribute for the products and I then would create a single page for handling the logic behind and it would automatically check that "ok this product has country X, so let's tell the view globally that the country of the selected product is X". Then that country attribute would be usable throughout the view, so you could also check in the "case studies" block what the country of the product was.
However, if you're talking about these blocks as their own entities (meaning that they should not share the same country attribute but rather their own), why would you even want to "share" the attribute in the first place? Can't both of the blocks just have their own country attribute in this case?
Here are few links I would suggest you check through if you're new with concrete5:
http://www.concrete5.org/documentation/general-topics/blocks-and-ar...
http://www.concrete5.org/documentation/developers/pages/single-page...
http://www.concrete5.org/documentation/general-topics/page-properti...
Br,
Antti