6
votes

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?

2
Hi Mikey, modifying the core com_content isn't really the best way to go around this. Have you considered a plugin which would allow you to attach an image to an article - I have created 2 extensions which provide very similar functions for 1.5 and the code is mostly transferable to 1.7. Would you be willing to try this as a solution? It would then not be a "core-hack" meaning upgrades to your CMS in the future would not break your modifications.udjamaflip
@udjamaflip thanks for reply, but I guess making a core change is a right option for me right nowmrGott
It would appear the same as the way you're currently doing it, if this is what you're worried aboutudjamaflip
I don't believe a core modification is ever the answer. As udjamaflip said, there is a plugin that would do the same thing - I'd strongly recommend going that route. It will save you hours of headache later when you have to upgrade (and you will/should for security purposes!)Hanny
@Hanny - What is the plugin name? Just to take a look, maybe I'll like that solution :)mrGott

2 Answers

1
votes

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')): ?>

1
votes

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.