1

I'm building a new Template for Joomla 3.x and I want to make it easy for the user...

In the template manager I want an 'Upload Photo' file-field. This is no problem; just define it in templateDetails.xml.

However, I would like to save the photo with different sizes under different preset names. The template is a responsive design so I want to use this picture as a background-picture using different sizes for different screen sizes (css using @media (max-width: xxxpx) ).

I know how to use Imagemagick to do the resize and save files to the location I want. But for the life of me I can't find out how and where to:

  • override the for the templateDetails (if necessary)
  • override the form submit action

I found :Joomla Override Plugin but this seems to be outdated.

There is quite a bit of information on overriding on the net but not quite what I'm looking for.

Can anyone help?

Marcel

  • After looking at the code some more I presume I need to override : administrator/components/com_templates/controllers/style.php Where do I put the override? – Marcel Meijer Jan 20 '15 at 15:47
  • As far as I can gather by doing some more searching I can write a plugin with an onExtensionBeforeSave. – Marcel Meijer Jan 20 '15 at 16:47
  • More research... It looks like a plugin for Jform with a onContentAfterSave would do the trick. So I would save the original file and in the onContentAfterSave I would create the resized versions and save them to the file system. – Marcel Meijer Jan 21 '15 at 9:42
1

The best way might be to write a plugin and use the right events:

onExtensionAfterSave

or

onExtensionAfterSave

The context would be "com_templates.style".

Example:

public function onExtensionAfterSave($context, &$templateTableStyle, $isNew = 0)
{
    if(com_templates.style == 'com_templates_style')
    {
        // do your work ...
    }
}

Another way might be to generate the images on-the-fly.

  • Shouldn't I write an override for JForm with onContentAfterSave? – Marcel Meijer Jan 21 '15 at 11:05
  • Why should you ? – Nils Rückmann Jan 21 '15 at 12:20

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.