0

As the title says I'm using joomla 3.4.8 I'm trying to customize the system component "com_content" what I want to do is to add an another columns on the '#__content" table in the database but the query in sql file is not executing.

I am also aware that I have to change the version of the com_content and the sql filename must be the version of the component. Please note that I didn't change anyting on the content.xml file I just added this tag.

 <!-- Runs on update; New in 2.5 -->
    <update> 
        <schemas>
            <schemapath type="mysql">sql/updates/mysql</schemapath>
        </schemas>
    </update>

this is the query I want to run in my /sql/mysql/3.1.0.sql

ALTER TABLE `#__content` ADD COLUMN `ucm_history_id` int(11), 
ADD COLUMN `preview_dashboard_name` varchar(250), 
ADD COLUMN `published_dashboard_name` varchar(250), 
ADD COLUMN `published_dashboard_script` mediumtext, 
ADD COLUMN `preview_workbook_name` varchar(250),
ADD COLUMN `published_workbook_name` varchar(250),
ADD COLUMN `preview_dashboard` tinyint(3),
ADD COLUMN `show_files` tinyint(3)

2 Answers 2

2

For the sake of answering your actual question, it is likely to be an issue with version numbers - make sure it is above the version in the database. Also note that there is the version of Joomla in the extension tag, and the component version in its own tag. Don't get these muddled.

However...

Important : You should not be touching the core files or database structure in any way, as patching the site may override your changes or cause other problems. For example, changing the version number on a core component could mean Joomla's own database updates may not be applied. On the patching note, you should not be on 3.4.8, any more. Unpatched sites, especially for security updates, are increasing their risk of being hacked.

If you want to add new fields to com_component, use the existing attribs field.

There is a guide to doing this with a plugin here

If you are making major changes to a core component, then that suggests it is time for a bespoke component to be built.

0

I do not know if this is hacky but I successfully added new columns in '#__content" table by creating another component that its task is just to alter '#__content' table and add the columns I needed.

4
  • 2
    I would not recommend altering core tables. If you additional columns, simple create a new table. You can then use join() clauses in your SQL query when selecting from the database. If you start changing the com_content version, you may run into issues in the future. Extend what is already there, do not alter/change it.
    – Lodder
    Apr 25, 2016 at 12:32
  • As @Lodder says, modifying the core tables is a bad idea. Next time you update there is a very likely possibility that you wipe out all of your work. Create a new table and join to it, simple as that with no hacking needed. You can join the new table using foreign keys to reference the com_content tables ID column.
    – Terry Carter
    Apr 25, 2016 at 23:59
  • But on our case updating the joomla to another version is not needed for us.
    – Voj
    Apr 26, 2016 at 2:42
  • @Voj Joomla is constantly growing/improving/updating to enhance performance, usability, security, etc. If you ignore new available updates to avoid potentially damaging your hackish programming practices, then it is likely that your site will become less secure and less welcoming to develop on. This is why you must not modify the core files/tables. Remember insecure sites are not just a problem for developers, they are a problem for your users who have instilled their trust in you / your software.
    – mickmackusa
    Jun 10, 2018 at 23:20

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.