PHP, hardcoding, posts

Permalink
Hello, I am new to concrete5. I mostly deal with wordpress. I have a new client who is wants to add specific functions to a concrete5 theme. They have chosen elemental and added ProBlog. I have read some of the documentatiion and the majority say that hardcoding is not recomended.

What there current concern is that they way posts are displayed. They want ot limit which blog post show up by date. They only want blog posts that have been submitted withing the last 24hrs to show up on the home page. Normally I would just right a script that would search the database within a specific time period, but that would mean opening a new database connection outside of concrete5. I am sure there is a better way, I have just not found it yet.

vixdoodle
 
maxx2097 replied on at Permalink Reply
Your own database queries might work, but I dont think its a good idea if the database schema changes in future releases.

I would suggest you create your own BlockType or override an existing one.

E.g. I overrided the page_list Block (there might be a special one for ProBlog) which basically displays a configurable list of pages (in your case blog posts).
To do this you can start by copying everything from concrete/blocks/<the block you want to override> to /application/blocks/ (be sure to keep the same subfolder structure).

Then you can start to modify the view template and/or the controller (your usecase should be handled in the controller).
You can even add more config options and store them in the database (modify the edit form and db.xml if you need extra fields).
It is quite straight forward from this point.

cheers

Maxx
JohntheFish replied on at Permalink Reply
JohntheFish
You may want to look at Pro Blog's capabilities in more detail. It may already include a date-ordered blog list with such filtering capabilities.

if not, that is the block you would need to either override or clone and edit into a new block.
DreamMedia replied on at Permalink Reply
DreamMedia
Is it concrete5 version 5.7 or 5.6?
vixdoodle replied on at Permalink Reply
vixdoodle
5.7
Sadu replied on at Permalink Reply
Sadu
Here's how I would approach this.

Use a page list block, set to display 10 posts (or whatever the maximum number of posts you would want to show). Set the order to newest first.

Create a custom template by copying the default view.php (there are docs on how to make a custom template for a block, read those).

In the main loop (approx line 27) , add something like this...
if ($page->getCollectionDatePublic() < strtotime('-24 hour')) {
break;
}


This is slightly less efficient than modifying the controller, but it's a lot easier/faster to implement.
Uranus replied on at Permalink Reply
Uranus
Hi,

Please check Problog options.There are some sorting and filtering options.

Thanks