Jump to content

Pages Category Images / Pages Searchable Text Fields

All Astronauts

Recommended Posts

Posted (edited)


Finally got this patched for 4.5/4.6 - will require no changes on your end at all. Might even be slightly faster (everything is datastore cached).

I'll be uploading 3.x tonight and it will be approved when it is approved as all things MP are these days. I'll also post here again after I submit with the low-down.


Edited by All Astronauts
Link to comment
Share on other sites

Posted (edited)

PCI Version 3.0.2 submitted.

4.5.x and 4.6.x compatible.

This moves all your images off the actual Pages Categories database table into a separate table.

You do NOT need to change any of your template code; this remains 100% compatible with whatever you are doing before.

Code examples for a reminder:

<img src='{file="$category->pcimage"}'>

The above where you have the $category variable available.

<img src='{file="$record->container()->pcimage"}'>

And that above for when you are in a record view template and have the $record variable available. You should be able to see the basic chain there record - then it call the container (which is the category the record is in) - and then our category image.

I do have caching of the new PCI database table. 99.99% it will never be a problem, when the category is being built out it actually double checks for the cache and if not there does a load from the DB directly. If something happens though, you can refresh the cache directly in the ACP on the Pages Databases menu option and any database Categories menu option with the obvious, can't miss button up top.

EDIT: Will edit/post when it is approved.

Edited by All Astronauts
Link to comment
Share on other sites

Posted (edited)

🤷‍♂️ maybe they're busy? EDIT: Will be awhile longer; you can use the same Giphy I already used.

ANOTHER EDIT: Daniel managed to find this one tiny thing out of the expansive pile of apps and plugins I have (There are a lot on my dev machine that never see the light of public day) that had this one thing leftover in a post-install routine. They probably aren't paying him enough.

Edited by All Astronauts
Link to comment
Share on other sites

  • 1 month later...

Installed and tried to update a category and got this error:

UPDATE `ipb_cms_database_categories` cms_database_categories  SET `category_pcimage`='monthly_2021_07/Themes.png.887b794354ac36921365535fe9f395f9.png',`category_show_records`=true,`category_can_view_others`=true,`category_allow_anonymous`=false,`category_forum_override`=false WHERE category_id=190 
IPS\Db\Exception: Unknown column 'category_pcimage' in 'field list' (1054)
#0 /home/jimiwikm/public_html/system/Db/Db.php(1154): IPS\_Db->preparedQuery('/*jimiwikm_siri...', Array)
#1 /home/jimiwikm/public_html/system/Patterns/ActiveRecord.php(520): IPS\_Db->update('`ipb_cms_databa...', '`category_pcima...', 'WHERE category_...')
#2 /home/jimiwikm/public_html/system/Node/Model.php(2452): IPS\Patterns\_ActiveRecord->save()
#3 /home/jimiwikm/public_html/applications/cms/sources/Categories/Categories.php(837): IPS\Node\_Model->save()
#4 /home/jimiwikm/public_html/system/Node/Model.php(3274): IPS\cms\_Categories->save()
#5 /home/jimiwikm/public_html/system/Node/Controller.php(420): IPS\Node\_Model->saveForm(Array)
#6 /home/jimiwikm/public_html/system/Dispatcher/Controller.php(90): IPS\Node\_Controller->form()
#7 /home/jimiwikm/public_html/system/Node/Controller.php(69): IPS\Dispatcher\_Controller->execute()
#8 /home/jimiwikm/public_html/applications/cms/modules/admin/databases/categories.php(61): IPS\Node\_Controller->execute()
#9 /home/jimiwikm/public_html/system/Dispatcher/Dispatcher.php(153): IPS\cms\modules\admin\databases\_categories->execute()
#10 /home/jimiwikm/public_html/admin/index.php(13): IPS\_Dispatcher->run()
#11 {main}


Link to comment
Share on other sites


@Jimi Wikman What version did you install? Just to be sure, you are using the application right? There is no code in the newest release that interacts with cms_database_categories other than to copy images to a new table and remove the PCI column from that table.

The error you are showing can only appear if you are using some old stuff somehow. Shoot me an account with ACP access (via PM) and I can take a quick look

Link to comment
Share on other sites

Fixed. I've asked for an accelerated review to get the patch out there.

The hitch was in how these are now added to Categories. It gets merged into the object and that's all well and good front-side, but troublesome with saves on the admin side. I got no idea how I missed this 🤷‍♂️ as it's rather apparent when hit. Effectively a one-line addition to fix.

Anyhoo, now that this is set for 4.5/4.6 I'll make a point to look at supporting thumbnail versions of the images and adding an additional field for an array of images which you can then throw at a carousel or something.

Link to comment
Share on other sites

And fixed again... Ya know, when IPS let us add fields to IPS application tables, this mod was a dorky simple set-it-and-forget-it thing. Now, ugh.

Put simply, I spaced that interacting with records would actually end up re-saving the category as well, and on the front-end, with the background image merged into the Category object that means when those edits/saves occur, it tries to save the Category with refreshed information and hits that background image and tries to save it in the Category table and the field ain't there, etc...

I fixed this, ate lunch to give some space, then gave it another run through. I believe I've done all the front-end testing possible. I've hit all the mod actions in record view and category view, plus new records saves, edits, and deletes. Commenting and Reviews on records cleared as well. 

If this still errors out after this (I don't believe it will but...) I'll need to rip off the band aid and make you guys edit your templates.

Instead of $category->pcimage to get at the thing it would be something different. Probably a template plugin like {pci=$category}.

Sorry for the hassle. Available when its available (3.0.6)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...