how to - Permalink from imported category included in code generator

7 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 10, 2020   (RSS)

By Steve99 - June 4, 2020


Sounds like a similar scenario as this post:

Referencing that post, essentially the "Restaurants" would be your "Artwork" records and the "Cuisines" would be your "Categories" records.

Hope this helps!


By Damon - June 4, 2020

Hi Josh,

The forum post link that Steve posted should have everything you need to get the results you are after.

Can you review and let us know if you have any questions about it that we can help with?

Damon Edis -

Hire me! Save time by getting our experts to help with your project.

By pixelMIGHT(Josh) - June 5, 2020

Thanks, guys. At a glance, that looks right. I'll be giving it a try next week and will post here about it. 

~ Josh

By pixelMIGHT(Josh) - June 9, 2020

The solution in the linked post worked well. 

I added this: 

// load records from 'art_categories'
list($art_categoriesRecords, $art_categoriesMetaData) = getRecords(array(
'tableName' => 'art_categories',
'where' => '`name` IN('.mysql_escapeCSV($artwork_imagesRecord['category:labels']).')',
'loadUploads' => false,
'allowSearch' => false,

To use this: 

<?php foreach ($art_categoriesRecords as $record): ?>
     <a href="/<?php echo htmlencode($record['permalink']) ?>" target="_self"><?php echo htmlencode($record['name']) ?> 
<?php endforeach ?></a>

Now, I just have one semi-related issue: 

The foreach outputs the array of "All, Paintings", for example. However, all of the artwork, whether drawings or print making, etc, is in the 'All category. How can I always skip the first key in this array so it never prints 'All'? 

Skipping the first item seems like it might be really simple, but I've tried using an array_slice and various if statements, but my novice self just can't figure it out. 

Thanks for any further guidance. 

By Steve99 - June 10, 2020

Hi Josh,

Glad to hear it helped.

This should work if you're looking to skip the first item of an array:

<?php foreach (array_slice($art_categoriesRecords,1) as $record): ?>


By pixelMIGHT(Josh) - June 10, 2020

Thank you! That is exactly what I needed. I was trying to do similar, but had the ",1" on the wrong side of the parentheses. I just don't write PHP enough to ever get even passably good at it... or even figure out what to search for sometimes. So, this is is much appreciated and saved me a lot of frustration.