Re: Joomla 2.5: Overriding ADMINISTRATOR/COMPONENTS/COM_CONTENT/MODELS/FORMS/ARTICLE.XML

737 views
Skip to first unread message

elin

unread,
Feb 3, 2013, 9:29:58 PM2/3/13
to joomla-de...@googlegroups.com
You know, it's an interesting thing, you could have used the links part of images and links to provide links for the images and just done a normal override.  But let's assume you are using those fields for something else.  So  there are some options. First  since that whole thing is json and i just ends up stored in a string in the same field you could use a plugin to replace that set of fields. 

Elin



On Friday, February 1, 2013 3:56:48 PM UTC-5, dbsaul wrote:

Creating an article in 2.5 there is the new feature for Images and Links.  
At present there is not a way to provide a link for the image.
So I set about to try and do this without hacking the Joomla core.

As I saw it there were two things to do:
1. Modify the file "article.xml" in "JoomlaRoot/administrator/components/com_content/models/forms".  
   This I did and it showed up on the slider panel for Links and Images when creating a new article.
   
   Here is the change I made to article.xml: (Changes in Bold)
   
 <fields name="images">
<field
name="image_intro"
type="media"
label="COM_CONTENT_FIELD_INTRO_LABEL"
description="COM_CONTENT_FIELD_INTRO_DESC" />
<field
  name="float_intro"
type="list"
label="COM_CONTENT_FLOAT_LABEL"
description="COM_CONTENT_FLOAT_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="right">COM_CONTENT_RIGHT</option>
<option value="left">COM_CONTENT_LEFT</option>
<option value="none">COM_CONTENT_NONE</option>
</field>
<field name="image_intro_alt"
type="text"
label="COM_CONTENT_FIELD_IMAGE_ALT_LABEL"
description="COM_CONTENT_FIELD_IMAGE_ALT_DESC"
class="inputbox"
size="20" />
<field name="image_intro_caption"
type="text"
label="COM_CONTENT_FIELD_IMAGE_CAPTION_LABEL"
description="COM_CONTENT_FIELD_IMAGE_CAPTION_DESC"
class="inputbox"
size="20" />
<field
name="image_intro_link"
type="url"
validate="url"
filter="url"
label="Link"
description="Link Description" />

<field
name="spacer1"
type="spacer"
hr="true"
/>

2. Use a Template override for the file "blog_item.php" taken from folder "JoomlaRoot/components/com_content/views/category/tmpl
   and moved to folder "/templates/site_name/html/com_content/category".

   I made the following changes at about line 130 in file "blog_item.php". 

(Changes in Bold)
   
     <?php  if (isset($images->image_intro_link) and !empty($images->image_intro_link)) : ?>
 <a href="<?php echo htmlspecialchars($images->image_intro_link); ?>" target="_blank"> 
     <?php endif; ?>

<img
    <?php if ($images->image_intro_caption):
      echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
         endif; ?>
src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>

     <?php  if (isset($images->image_intro_link) and !empty($images->image_intro_link)) : ?>
 </a>
     <?php endif; ?>


This did what I wanted which was to allow me to specify links for images when I added the image.

Now, I am left with the last step which I do not know how to do.

Is there a documented/proper method, similar to the Template Override that I did in step 2 that will move the modified
"ARTICLE.XML" out of the Joomla core and prevent loss of this enhancement when Joomla is upgraded ?.

Thanks,
Dave   
   

dbsaul

unread,
Feb 4, 2013, 12:35:03 AM2/4/13
to joomla-de...@googlegroups.com
Elin, you are correct.  I did not see the approach using the links. 
I am not using the links so just doing the normal override is the simpler approach.
As to the options you mentioned, I have been catching up on using the plug-in method which allows core classes to be overridden.

Thanks much for your input,
Dave
Reply all
Reply to author
Forward
0 new messages