3

Joomla 3.4.4

I have a single category called 'Departments'. This contains hundreds of articles.

Is there any way I can set the same 'Full Article Image' for each of these articles? See image;

enter image description here

I understand I can set an image for the 'Departments' category, and display this within the article but that's not what I require. I need all the articles to display the same Full Article Image.

If I could set the Full Article Image to be the same as the category image that would work.

Perhaps I am overlooking something obvious?

  • Go with a an alternative menu item for this specific category. – FFrewin Sep 11 '15 at 9:19
  • Not sure I understand @FFrewin Could you explain briefly please? Thanks. Also updated question, it's the Full Article Image I need not the intro image. – jonboy Sep 11 '15 at 9:39
  • I would like to give a detailed answer, but I am currently out of time. Maybe later. – FFrewin Sep 11 '15 at 9:50
3

Thought I'd give my 2 cents on this. I'm sure there are other ways, but this is the one I came up with and tested.

So, using a system plugin and JS, you can set a value for the full article image input.

Here is the code I've written:

class plgSystemMyPlugin extends JPlugin
{    
    public function onBeforeCompileHead()
    {
        $app    = JFactory::getApplication();
        $option = $app->input->get('option');
        $view   = $app->input->get('view');
        $layout = $app->input->get('layout');

        // Only execute via the backend
        if (!$app->isSite() && $option == 'com_content' && $view == 'article' && $layout == 'edit') 
        {
            $doc = JFactory::getDocument();

            $doc->addScriptDeclaration(
                "jQuery(document).ready(function($){
                     $('#jform_images_image_fulltext').val('images/powered_by.png');
                });"
            );
        }   
    }   
}
  • It firstly checks to see if you're in the backend.
  • Then it checks to see if your in the correct component, view and layout.
  • Then injects jQuery into the <head> which changes the value of the input field.

Hope this helps

  • Thanks @Lodder So, this way I simply open up the article for editing in the back-end and the JS injection does the rest? – jonboy Sep 11 '15 at 10:03
  • @johnny_s - Yup, that's correct :) Oh I almost forgot to mention, you will also need to change the default image I've used for the value to whatever suits your needs ;) – Lodder Sep 11 '15 at 10:04
  • @johnny_s - You're welcome. Glad it helped – Lodder Sep 11 '15 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.