Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add new image field to Joomla 1.7 com_content

I'm trying to make some changes to com_content component of Joomla 1.7 There are not many docs on specific topic for Joomla 1.7

Maybe you could help me out on this one.

I want to have a separate field for extra image in com_content, specifically to Featured view.

In the administrator's part I managed to add the field - just in html, then into xml file and finally to DB.

Now I'm trying to get that record displayed in my custom html view for Featured articles.

I just used simple code echo $this->item->addimage; but unfortunately it's not displayed.

Any ideas how to achieve that?

Thanks!

And one more thing, as far as I have noticed, component development structure, DB registration and so on, has been changed in Joomla 1.7. Any helpful link(s) where everything is explained well?

like image 950
mrGott Avatar asked Oct 12 '11 22:10

mrGott


2 Answers

com_content is really not the way for creating variable content in joomla anymore. It's still the same unflexible code since mambo days. You should try solutions like K2, flexicontent or my favourite ZOO. They are easy to learn and you can do lots of cool stuff with them. Extra Fields? No Proble., Some of them already exist for Joomla 1.7/2.5. Hacking the core is always bad. Mainly because you loose your update path.

like image 37
Mike Avatar answered Oct 23 '22 19:10

Mike


Well. If you are sure that your implementation of what you have done works. ie. Embedded image or simply URL link from field you have added are stored in the database have a look into frontpage file /components/com_content/views/featured/tmpl/default_item.php

There you should place your $this->item->addimage variable like:

<img src="<?php echo $this->item->addimage; ?>" />

If you store URL link, or

<img src="image/png;base64,<?php echo $this->item->addimage; ?>" />

if your store the image as RAW base64 encoded data


Edit: This should solve your problem if you add your articles from frontend (if backend, just let me know)

  1. Firstly create a new column in jos_content table like:

'addimage' varchar(255) DEFAULT NULL

Then modify the following files:

  1. ../com_content/views/featured/tmpl/default_image.php [LINE: 29]

    29:#</h2>

    30:#<?php endif; ?>

    32: <?php if(!empty($this->item->addimage)): ?>

    33: <img src="<?php echo $this->item->addimage; ?>" alt="ADDIMAGE" />

    34: <?php endif; ?>

    36: #<?php if ($params->get('show_print_icon') || $params->get('show_email_icon') || $canEdit) : ?>

  2. ../com_content/models/articles.php [LINE: 160]

    160: # $this->getState(

    161: # 'list.select',

    162: 'a.id, a.title, a.alias, a.title_alias, a.introtext, a.addimage, ' .

    163: #'a.checked_out, a.checked_out_time, ' .

  3. ../com_content/models/forms/article.xml [ADD SOMEWHERE]

    <field id="addimage" name="addimage" type="text" label="Add Image" class="inputbox" />

  4. ../com_content/views/form/tmpl/edit.php [LINE: 82]

    82: #<?php echo $this->form->getInput('created_by_alias'); ?>

    83: #</div>

    85: <div class="formelm">

    86: <?php echo $this->form->getLabel('addimage'); ?>

    87: <?php echo $this->form->getInput('addimage'); ?>

    88: </div>

    90: #<?php if ($this->item->params->get('access-change')): ?>

like image 59
WooDzu Avatar answered Oct 23 '22 19:10

WooDzu