Most rated articles
Permalink
Hi. I'm a new in c5 world. I came from drupal. My question is: how to create a block with most rated 5 articles? And how to configure this block for 3, 5 or 7 most rated articles?
Thanks.
Thanks.
Thanks for "answers". I'm back to drupal :))
Sounds like a good question for the totally random web show this morning if you are on Pacific US time (or this evening in the UK)
Aw Shucks.
The thing with c5 is its flexibility so, there's not a single way to do this. :))
I'd say something like this:
1. Create a page attribute of type "Rating", give it a handle you can remember
2.a. (harder but you learn more) Create a new block with which you can ask the parameters, in your situation "How many articles to show?", Designer Content add-on is a great help for starting out with the block creation
2.b. (easier but you learn less) Copy the core block called "page_list" to start with. Modify its edit-form to ask the correct questions.
3. After you've created the block either way, modify its controller's view() method. This method will pass data to the view and this is where you do your custom search
4. Modify the block's view.php to show the data in correct format you desire
For doing the custom search, you need to search and sort by the Rating attribute you created in step 1. For this you can find out detailed example in the core block called "search" but here's some calls to get you started with. This should go to your block controller:
Hope it helps! Sorry for not being here 5min after you posted this!
Best,
Antti / Mainio
I'd say something like this:
1. Create a page attribute of type "Rating", give it a handle you can remember
2.a. (harder but you learn more) Create a new block with which you can ask the parameters, in your situation "How many articles to show?", Designer Content add-on is a great help for starting out with the block creation
2.b. (easier but you learn less) Copy the core block called "page_list" to start with. Modify its edit-form to ask the correct questions.
3. After you've created the block either way, modify its controller's view() method. This method will pass data to the view and this is where you do your custom search
4. Modify the block's view.php to show the data in correct format you desire
For doing the custom search, you need to search and sort by the Rating attribute you created in step 1. For this you can find out detailed example in the core block called "search" but here's some calls to get you started with. This should go to your block controller:
// Load and create searching list for your pages Loader::library('database_indexed_search'); $list = new IndexedPageList(); // Find your newly created rating attribute key: $ak = AttributeKey::getByHandle('handle_you_created_in_step_1'); if (is_object($ak)) { // Found the key, now sort (desc) by this key: $list->sortBy($ak, 'desc'); } // And finally get the number of desired results: $desiredResults = 5; // This is the variable you get from the block settings passed by the user who added the block on the page $myResults = $list->get($desiredResults);
Hope it helps! Sorry for not being here 5min after you posted this!
Best,
Antti / Mainio
Thanks for the reply and I apologize for rushing to get a quick response to the first question.
Concrete5 seems to be powerful and flexible.
Now, without rushing me :)), please answer me another question: from what I've seen C5 is oriented to page concept. If you create an article , c5 presents him as page management interface, right? In aest case, if we have 500 articles,C5 show me in Site map 500 pages to manage? How can i create an interface that can filter items according to category in which they were published? And still there the client can perform deletion or archiving articles? Sometthing like the picture attached. Thanks again and sorry for my bad english :)
Concrete5 seems to be powerful and flexible.
Now, without rushing me :)), please answer me another question: from what I've seen C5 is oriented to page concept. If you create an article , c5 presents him as page management interface, right? In aest case, if we have 500 articles,C5 show me in Site map 500 pages to manage? How can i create an interface that can filter items according to category in which they were published? And still there the client can perform deletion or archiving articles? Sometthing like the picture attached. Thanks again and sorry for my bad english :)
No problem!
Yes, you're 100% correct c5 represents almost everything in Pages (which I think is quite great idea in terms of flexibility and out-of-the-box/0-loc support for custom attributes), think of them as nodes in drupal. Even the core-built discussion forums add-on represents different forums as different pages.
You have a page searching view under Sitemap => Page Search where you can do custom searches and filter out results.
If you want to build something more custom, I'd suggest copying that one and starting out building a new Dashboard Single Page for the thing you need.
Here's a bit more on building your custom single pages:
http://www.concrete5.org/documentation/developers/pages/single-page...
http://www.concrete5.org/documentation/how-tos/developers/basic-mvc...
I bet there was even a more throughout guide in the how-tos but cannot find it now. Search the how-tos and google for "single pages" or "concrete5 single pages".
Antti
Yes, you're 100% correct c5 represents almost everything in Pages (which I think is quite great idea in terms of flexibility and out-of-the-box/0-loc support for custom attributes), think of them as nodes in drupal. Even the core-built discussion forums add-on represents different forums as different pages.
You have a page searching view under Sitemap => Page Search where you can do custom searches and filter out results.
If you want to build something more custom, I'd suggest copying that one and starting out building a new Dashboard Single Page for the thing you need.
Here's a bit more on building your custom single pages:
http://www.concrete5.org/documentation/developers/pages/single-page...
http://www.concrete5.org/documentation/how-tos/developers/basic-mvc...
I bet there was even a more throughout guide in the how-tos but cannot find it now. Search the how-tos and google for "single pages" or "concrete5 single pages".
Antti