Where to place media file override in template

  • Robert Emenecker
  • Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 4 months ago #72301 by Robert Emenecker
Where to place media file override in template was created by Robert Emenecker
Hi all,

I need to do major adjustments to one of the calendar theme stylesheets. To avoid risk of overwriiting, I want to put the override in my site's template. I've reviewed the info available on Joomla regarding overrides at the following link: docs.joomla.org/Understanding_Output_Ove...Media_Files_Override .

The file I need to override is ./media/com_eventbooking/assets/css/themes/default.css
I've tried the following in my template directory:
./templates/mytemplate/assets/com_eventbooking/css/themes/default.css
./templates/mytemplate/css/com_eventbooking/default.css
./templates/mytemplate/css/com_eventbooking/themes/default.css

None of them worked. I'm wondering if the JHtml::stylesheet() call to load the style sheet does not allow for an override.

Any suggestions?

Thanks,
Rob

Please Log in or Create an account to join the conversation.

More
9 years 4 months ago #72304 by James Riley
Replied by James Riley on topic Where to place media file override in template
Rather than creating a full-out override, you can place all your changes into /media/com_eventbooking/css/custom.css as that file is never supposed to overwrite on upgrade.

Looking at the Joomla overrides docs, I would say that /templates/mytemplate/css/com_eventbooking/themes/default.css is the correct location... but as you alluded to, that will only work IF stylesheet override is allowed (as per note at the overrides docs). Looks like EB uses JFactory to link stylesheets...
Code:
<components/com_eventbooking/controller/controller.php> $document = JFactory::getDocument(); ... $document->addStylesheet($rootUrl . '/media/com_eventbooking/assets/css/themes/' . $theme . '.css');
...and JFactory's docs do not talk about an override option like the Joomla Doc's JHtml::stylesheet example talks about, so I don't know if the jFactory method permits this or not.
Go for adding to custom.css and all will be right with the world again :)

James Riley .: EventBooking user since 2014 ::: JoomDonation user since 2016 :.
.: grfx & web design / IT / AV @ St. Therese Institute of Faith and Mission, Bruno, SK, Canada :.

Please Log in or Create an account to join the conversation.

  • Robert Emenecker
  • Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 4 months ago #72308 by Robert Emenecker
Replied by Robert Emenecker on topic Where to place media file override in template
Thanks James,

Was hoping to do a proper override, because I literally need to strip out most of the styles and restyle the entire calendar. It would be vastly easier to style an unstyled calendar, then worry about catching all of the declarations as overrides in a second stylesheet. Going about it that way, usually means MORE styles in the second sheet to UNDO what was not needed to begin with. And, now we are also loading two stylesheets.... the original styles and all of the new styles.

I use jQuery Easy with Profiles to control JavaScript and CSS loads, as well as providing for conditional loading of stylesheets. I think a better approach will be for me to disallow the calendar themes style sheet and then add in my custom CSS.

Alternatively, I may look at the core code and see how much work it will be to change the calling method for loading the stylesheet to one that allows a parameter flag for overrides.

Thanks,
Rob

Please Log in or Create an account to join the conversation.

  • Robert Emenecker
  • Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 4 months ago #72454 by Robert Emenecker
Replied by Robert Emenecker on topic Where to place media file override in template

James Riley wrote:

Code:
$document = JFactory::getDocument(); $document->addStylesheet($rootUrl . '/media/com_eventbooking/assets/css/themes/' . $theme . '.css');
...and JFactory's docs do not talk about an override option like the Joomla Doc's JHtml::stylesheet example talks about, so I don't know if the jFactory method permits this or not.
Go for adding to custom.css and all will be right with the world again :)


Right. Unfortunately, one of the shortcomings with the Joomla CMS API's JDocument object is the lack of remove methods. While there are methods for adding scripts, styles, stylesheets, etc., there are no similar *remove* methods, such as...
Code:
$cssUrl = $rootUrl . '/media/com_eventbooking/assets/css/themes/' . $theme . '.css'; if (JFile::exists($cssUrl) { $document->removeStylesheet($cssUrl); } $document->addStylesheet($templateUrl . DS . 'css/'eventbooking/calendar.css');

If you have one, you really ought to have the other.

To be clear, this is a Joomla CMS API shortcoming :angry:, not an EB issue.

For the time being, I've decide to use jQuery Easy Profiles to customize the stylesheet loaded for the EB calendar page. It's not that I see it as a better approach than to use the custom.css stylesheet already provisioned in EB. It is just that as I add a few more extensions that also have their own stylesheets (and overrides needed), it will be easier for me to manage these overrides from a single location, rather than one-off adjustments on a case-by-case basis.

Once the heavy lifting on the project is done, if I find that the stylesheet override via jQuery Easy Profile is the only one (or one of just a few), then I'll revisit the issue. :)

---Rob

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc