Wednesday, May 2, 2012

Adding Custom Field in com_content

Hi Everybody,

I am several hours into this problem and looking at this post. Finnaly I think I have what I wanted. So lets say I want to add a custom field named "url" so my users could submit on every article an "url" field with some link:

1-changed joomla database in "jos_content". Using phpmyadmin I executed this query

ALTER TABLE `jos_content` ADD `url` MEDIUMTEXT NOT NULL




2-In
/components/com_content/views/article/tmpl/form.php

I added somewhere around line 100 this code:
Code:

<label for="url">link: </label>
<input class="inputbox" type="text" name="url" id="url" size="40" maxlength="100" value="<?php echo $this->escape($this->article->url); ?>" />


This will place field in frontend article submission

3- In
/administrator/components/com_content/admin.content.html.php

around line 790 I added this code
Code:

<td><label for="url"><?php echo JText::_( 'url' ); ?></label></td><td><input class="inputbox" type="text" name="url" id="url" size="40" maxlength="255" value="<?php echo $row->url; ?>" /></td>"



This will place url field on admin backend

4-In
/libraries/joomla/database/table/content.php

around first lines added this code
Code:

var $url            = null;




5-In
/administrator/components/com_content/controller.php

around lines 1300 added this code
Code:

$row->url= $item->url;



6-In

components/com_content/views/article/tmpl/default.php


around line 20 added this code
Code:

<?php echo $this->escape($this->article->url); ?>


this will insert field when viewing article layout

No comments:

Post a Comment