3

I'm writing a console plug-in in Joomla 4.2.3 to add tags to content items based on field values that'll run on a cron task.

I've generally got it working ok, my code adds a row to the contentitem_tag_map table to add a tag to a content item.

My issue is that the contentitem_tag_map table has a field called core_content_id which seems to relate to the core_content_id in the ucm_content table and about half of my content items do not have a corresponding row in the s3ib7_ucm_content, in which cases I do not have anything to set that field to.

What should I be doing?

Every time I add a tag to an item, should I be adding a row to ucm_content and ucm_base tables?

Should I be doing this some other way, rather than just trying to add tags via SQL queries?

I have content versioning turned off in com_content and com_tags.

1 Answer 1

1

You should insert records in all relevant tables. There is some code which relies on the ucm_base records. Although it's not used by core, it can be used by 3rd party extensions. ucm_content table is used more widely, especially in frontend. It's used by Tags component to show list of tagged items, as well as by tag modules.

Generally it's a bad practice to be inserting database records manually. Best use existing APIs. Tagging is now handled by a plugin in behaviour group which runs on table events. So you could use the content model or the table class to manage this.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.