6 posts by 2 authors in: Forums > CMS Builder
Last Post: May 14   (RSS)

Hey Jesus, 

So it looks like you're trying to insert a custom first row into your results with a value of 0 and label of root. You can do this by converting the field use custom MySQL, then adding a first custom row. I found a Stackover flow post that show's how to do that here:

https://stackoverflow.com/questions/24771349/how-can-i-add-a-custom-row-to-the-top-of-a-select-result-set

So you'll need to change the CatRoot field List option from 'Get options from database (advanced)' to 'Get options from MySQL query (advanced)'. Then add the following custom MySQL command:

SELECT '0' as num, 'Root' as title
UNION ALL
SELECT `num`, `categoria`
  FROM `<?php echo $TABLE_PREFIX ?>categorias`

This is just example code, so you might need to make a few changes to get it working with your setup. 

Cheers,

Greg

Greg Thomas
PHP Programmer - interactivetools.com

Thank you Greg this worked :)

Now, how can I save the record for this field (as I'm thinking to relate this record for my Sites section like this:

0|Root
1|Arte y Cultura
2|Arte y cultura/Nuevo León
3|Arte y cultura/Nuevo León/Centros Culturales
4|Arte y cultura/Nuevo León/Galerias de arte
5|Ciencia y tecnologia
6|Ciencia y tecnologia/Ciencias de la Tierra y del Espacio
7|Ciencia y tecnologia/Ciencias de la Tierra y del Espacio/Astronomía
8|Deportes y entretenimiento
ETC

I'm thinking just one field (in place of two) as I'll use it later in my Sites section in order to build the permalink for detailed pages.

Thanks!

Jesus

Hey Jesus,

So you want to display the breadcrumb (the parent records title field of each entry in the drop-down) as the records are from a category section?

Do you have a field that contains the value you want to display? For example, for the record Centros Culturales, do you have a field that contains Arte y cultura/Nuevo León/Centros Culturales?

Greg Thomas
PHP Programmer - interactivetools.com

No, but that's exactly what I'm trying to do.

Right now my category table looks like this:

  • Title (Category name)
  • Subcategory of (select list)
  • Description
  • permalink

Then in my Listing table I currently have:

  • Title
  • Category (list of categories from my category table)
  • URL
  • Description
  • permalink

I want to display one page per each category with all the Sites (listings) 

Example:

http://mysites.com/category/subcategory1/subcategory2/

That will display all listing from subcategory2

So... I'm trying to understand how can I accomplish this.

At this point I might need to add/include new fields on any table I'm just trying to make it work or to adjust the logic of all this in order to make it work

Thank you for your help!

Jesus

Hey Jesus,

Thanks for the extra details. You'll need to update the category dropdown in the listings table so that it shows the permalink as the label. Then you can use the getRecords function to pull all of the relevant listings on the category detail page on the front end of the site.

Cheers,

Greg

Greg Thomas
PHP Programmer - interactivetools.com