Cyprich.com

Occasionally Relevant Insights from a Software Builder

By

Add a url Field to jos_content in Joomla

A useful feature for Joomla would be a way to store a URL for an article that only links to another site. You would have to manually create the link within a Joomla article which involves quite a bit of steps to do. I would rather create the title, add the URL, write a brief description of the site, and post the article to my web site.

I was looking at creating a custom component to do this, but while looking at the jos_content table, which contains the articles in Joomla, I noticed a urls field. None of my sites used that field, so this would be a good candidate to hold an article’s URL. The URL text box will look the following:

URL Field in Joomla Article

If you enter a URL here, it will be saved and can be used to build a link to the page content.

How To Add a urls Field

Adding a urls field to a Joomla article is not an easy task for a novice webmaster. A good free tool for editing PHP content is Eclipse. Start your editor, and do the following procedure:

  1. Open admin.content.html.php in the administrator/components/com_content/ folder.
  2. Find the _displayArticleDetails function.
  3. Add the following code at the end of the function before the </table> tag:

    <tr>
      <td valign="top" align="right">
        URL:
      </td>
      <td>
        <input class="text_area" type="text" name="urls" id="urls" size="40" maxlength="254" value="<?php echo $row->urls; ?>" />
      </td>
    </tr>

A URL field will now be displayed when you are editing an article. Anything you enter here will be saved in your Joomla database. Part 2 will show you how to use the URL that was saved with the article.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.