Blog with multiple categories

10 posts by 3 authors in: Forums > CMS Builder
Last Post: May 15, 2017   (RSS)

By kovali - April 10, 2017

Hi,

I'm trying to build a blog with different categories, every category can have many stories. The list of all categories and list of corresponding stories should always be shown on the same page. Now, when I click on a category I only get the first story for that category... But I want it to show ALL stories for that category.

The code that I'm using now:

<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'beheer/lib/viewer_functions.php';
$dirsToCheck = array('/home/weballbe/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records from 'pe_blog_rubrieken'
list($pe_blog_rubriekenRecords, $pe_blog_rubriekenMetaData) = getRecords(array(
'tableName' => 'pe_blog_rubrieken',
'loadUploads' => false,
'allowSearch' => false,
));

// load records from 'pe_blog'
list($pe_blogRecords, $pe_blogMetaData) = getRecords(array(
'tableName' => 'pe_blog',
'where' => whereRecordNumberInUrl(1),
'loadUploads' => true,
'allowSearch' => false,
));

?>

I think it has something to do with 'where' => whereRecordNumberInUrl(1), why it's only showing 1 story but don't know the correct PHP code to get all stories for one categorie.

Anybody that can help me please ?

Thanks !

By kovali - April 10, 2017

Is it possible to have 2 lists of different tables on one page anyway ??

By ross - April 14, 2017

Hi there

Thanks for posting.

It is possible to display two lists on one page.

To start with, though, I recommend simplifying and focusing specifically on a page that lists all your blog posts.

Don't add anything about categories or single records or multiple lists.

Just build a page that lists all your blog posts regardless of category.

Once you have that, attach a copy of your file (instead of pasting code into a post), and I can review from there.

Does that make sense? Let me know any questions or feedback.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By kovali - April 25, 2017

Hi Ross,

I've build a page that simply lists all blog posts, see file attached please.

The result in the browser: http://pretecho-opleiding.be/blogtest.php 

Best regards,

Koen

Attachments:

blogtest.php 10K

By kovali - April 28, 2017

Hi Ross, how will I continue from here... ?

By kovali - May 8, 2017

Anybody ?

By gkornbluth - May 8, 2017 - edited: May 8, 2017

Hi Kovai,

One approach might be to set up a way to identify the different groups of blogs. I usually do that by setting up a multi record "Categories" section with a "Category" text field.

Next, set up a pull down list field in my blog section that gets its values and labels from the "Category" field in the "Categories" section, make it a required field, and "assign" each blog story to a particular category with that pull down. (this keeps everything nice and uniform, so searches don't go awry.)

Next on they blog list viewer, set up a similar pull down that gets its values from the Category field in the Categories section, (also make this a required choice using error checking) so that the visitor can choose from the same category list.

You can then use that choice to set a 'where' value to limit the blog posts shown to only that category.

It's pretty easy once you get going, and there's a lot more on the details in my CMSB Cookbook recipes.

Good luck

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By gkornbluth - May 9, 2017

Hi Koen,

I'm not able to access any examples right now, but have a look through the recipes in the CMSB Cookbook. You'll find examples there.

If you're not a subscriber, you can get a trial subscription. just follow the link below.

Good luck,

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By ross - May 15, 2017

Hi kovali

Just wanted to check in on how you are making out with your blog. 

Did you find what you need in The Cookbook?

Let me know if you still have any questions.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/