30 Comments

  1. Raj

    Hi,

    Thanks for your post on Adding custom columns/fields to Joomla article.

    I am building a website with Joomla and have beed trying to look for a tool that would allow me to add custom fields
    into articles…after looking at various tools I was also thinking of manually adding the field in jos_content … but did not proceed … cause i was concerned whether i would be affecting the other operations in joomla. But since i have seen your post .. i am more convinced to try it out …

    Your instructions :
    1. “Edit administrator/components/com_content/models/article.xml add:” ( not sure what to add here in article.xml, can you please explain further…)

    2. Also would you know whether modifying the *_content table would cause any issues in the other operations of Joomla?

    Also it would be a great learning experience if you could tell me why we have to do each of the steps after manually creating the fields … or maybe you can forward a link to some documentation …

    Thank you very much.

  2. SPK

    hey rana.

    the ppt file helped a lot.
    i was able to follow it and add the custom field to myu articles in admin without issue.
    so thanks; nice work.

    but now i am struggling to use it in my template…
    specifically, i want to draw that value in “test” out to the category page that lists articles on my site.

    i can modify the html, but am unsure of how to pass the new variable so that i can use it in the template. any help greatly appreciated.

    thanks again.

  3. Sitthya

    Hi there,
    Very smart post! Thank you very much for the effort.
    I followed step by step what you write in the ppt but I still have an issue when I save my article, it says :

    Unknown column ‘test’ in ‘field list’ SQL=UPDATE `jos_content` SET `title`=’Arbres et résultats template’,`test`=’xcd’,`alias`= …

    Note : I create the coumn ‘test’ through phpmyadmin.

    Thank you in advance for your response,
    Have a good day.

  4. Philipp

    Hi,

    Nice post, worked just fine.
    I just wondered how I can make use of this field in my frontend template? How can I show the value somewhere?

    Thanks in advance!

  5. This is what I am looking for! thanks! MAN

    1 thing, I added a custom filed, called “release date”, I wanna it to be displayed on frontpage to replace the “created date”

    but seems the new field can not be added to front page.

  6. santanu

    Thanks a lot for your help. Its really works for me. But one thing is still not clear how I will display this custom field in the frontend.
    please help me in this regd.
    Thank you agian…..

  7. Dewa

    Adding custom columns to the category list layout

    The category list layout now is able to show in the heading the title, date, author and hits. I would like to add a column displaying the content of a custom field I added to my articles, for example ISBN number and the price of a book I wrote an article on.

    So I’m able to add custom fields to an article, but I would like these fields to show up in a new column in the category list layout.

    Any suggestions on how to do this?

    • Hi Dewa,
      Just edit bellow files and change commented (bold) lines. Here i take isbn as a extra field for jom_content table.

      E:xampphtdocsjoomlacomponentscom_contentmodelscategory.php
      function _buildQuery($state = 1)
      {
      global $mainframe;
      // Get the page/component configuration
      $params = &$mainframe->getParams();

      // If voting is turned on, get voting data as well for the content items
      $voting = ContentHelperQuery::buildVotingQuery($params);

      // Get the WHERE and ORDER BY clauses for the query
      $where = $this->_buildContentWhere($state);
      $orderby = $this->_buildContentOrderBy($state);

      $query = 'SELECT cc.title AS category, a.id, a.title, a.alias, a.title_alias, a.introtext, a.fulltext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,' .
      ' a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.attribs, a.hits, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,a.isbn,' .
      ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
      ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug,'.
      ' CHAR_LENGTH( a.`fulltext` ) AS readmore, u.name AS author, u.usertype, g.name AS groups, u.email as author_email'.$voting['select'] .
      ' FROM #__content AS a' .
      ' LEFT JOIN #__categories AS cc ON a.catid = cc.id' .
      ' LEFT JOIN #__users AS u ON u.id = a.created_by' .
      ' LEFT JOIN #__groups AS g ON a.access = g.id'.
      $voting['join'].
      $where.
      $orderby;

      return $query;
      }

      E:xampphtdocsjoomlacomponentscom_contentviewscategorytmpldefault_items.php
      ..............................................................
      ................................................................
      ....................................................................
      <td align="center" class="sectiontableheaderescape($this->params->get('pageclass_sfx')); ?>" width="5%" nowrap="nowrap">
      lists['order_Dir'], $this->lists['order'] ); ?>

      <td align="center" class="sectiontableheaderescape($this->params->get('pageclass_sfx')); ?>" nowrap="nowrap">
      ISBN

      .......................................
      .............................................
      ................................................

      escape($item->hits) ? $this->escape($item->hits) : '-'; ?>

      escape($item->isbn); ?>

      Please dont forget change colspan value.

      If any query just ask me. Best of luck.

      –Rana

  8. Wael

    Hi

    Thank you for the post.

    My new field is already in the Backend – and I can add what value I want , however when I publish the article , I have a problem.

    I can see the new field in the article view , however I am not able to see it in Category Blog view – where usually I have the articles with “read more”. I cannot see the field there.

    Any tips please??

    What I did is :
    go to:

    rootcomponentscom_contentmodelscategory.php

    Scroll to about line 361 and add new fields at the following code:

    $query = ‘SELECT cc.title AS category, a.id, a.title, ……..

    But no results – still cannot see it there.

    Help 🙂

    • Hi
      Have you modify componentscom_contentviewscategorytmpldefault_items.php file? You should have change this file also if you want to see your newly added field in your category list layout. I have explain details in my previous comment. If you need remote support let me know.

      -Rana

  9. Sacha

    Hi Rana,

    It looks like there is a missing line in your article above:

    “Edit administrator/components/com_content/models/article.xml add:

    ?????? <—– nothing shows here!

    In the first params section for instance below the access entry."

    can you write what is supposed to go in the ??? space for the article.xml document?

    thanks for your cool blog,

    sacha

  10. max

    Hi,

    Nice post, I’m working with j1.5.22 and on the backend your customization worked fine.
    Wondering how can I show now my new fields on the frontend side. Which php files should be changed to show fields in the article page?

    Thanks in advance!

    • Hello
      E:xampphtdocsjoomlacomponentscom_contentmodelscategory.php
      AND
      E:xampphtdocsjoomlacomponentscom_contentviewscategorytmpldefault_items.php

      Few days ago i have discussed about this, please check (December 14, 2010 at 1:37 PM) Reply. If any further query let me know.

      -Rana

  11. mister mouse

    Hi Saidur,

    How would you add the custom fields in Joomla 1.6? Your explanation of how to do it for 1.5 was pretty easy but since file structure is different in 1.6 i could figure it out. Thanks

  12. efrab

    Hi there great post

    But I was wondering does this works for Joomla 1.6?

    I am trying this titorial but without any results since some files are just not there in Joomla 1.6….

    I would love to add a custom filed like this in Joomla 1.6

    Hope you can help….

  13. Hi,
    I dont know if some of you have this problem, but my joomla site is so slow when saving an article. i read in internet that maybe is mysql configuration, i had cahnged query_cache size with 64m and key_buffer with 128mb, my server is pentium 4 2.8ghz and 1gb of ram, and still being same thing. so slow, several minutes to save an article.
    At somewhere i read that maybe hiding some fields from the listed articles in article manager, could reduce the queries joomla does to show articles after saving or aplying. could you please help me telling me how to hide or delete some fields from showing, like frontend, access and ID? maybe could help me to accelerate the saving time of articles. thanks in dvance!

    p.d. i have 13500 articles

Leave a Reply