CMS MADE SIMPLE FORGE

CMS Made Simple Core

 

[#8881] cms_stylesheet ability to create named groups of combined stylesheets: via name suffix etc

avatar
Created By: Jonathan Parker (JPDabnis)
Date Submitted: 2013-01-31 11:09

Assigned To: Tapio Löytty (Stikki)
Resolution: Accepted
State: Open
Summary:
cms_stylesheet ability to create named groups of combined stylesheets: via name suffix etc
Detailed Description:
This is the real world example of the issue that my request would solve.
Using CGSmartImage within stylesheets assigned to a template that is device
aware : monitor; tablet; handheld etc and as such supplying varying template
code.
Styles are taken care of with media quires within the individual stylesheets
which basically works well. However when using CGSmartImage to embed(base64)
images used within the stylesheets the media queries select in / out where
required, but image code that is not required for say 'handhelds' is still
served and can be quite heavy.
A solution would be to switch between differing 'sets' of combined style sheets,
thereby reducing payload. In this case a simple css filename suffix type filter
would suffice: {cms_stylesheet combine="mb_*"} to form seperate groups of
combined stylesheets.

I hope the above is clear.
Jonathan

History

Comments
avatar
Date: 2013-01-31 11:33
Posted By: Robert Campbell (calguy1000)

This is a valid idea

The name_parameter could be modified to take a comma separated list of names, or
a wildcard.   It would use the order specified, or alphabetic order to determine
the order to append the stylesheets.  And be completely independent of the
template specified.

i.e:  {cms_stylesheet name='mb_*'} would use alphabetic ordering...  
{cms_stylesheet name='mb_3,mb_4,mb_1'} would use the specified order.    You
would not be able to combine wildcard with comma separated lists.

Additionally, there should be a parameter something like: {cms_stylesheet
set_mediaquery='whatever'} to force a media query output on the <link> tag
regardless of what is attached to the stylesheets themselves.

Also,  a minify parameter would be useful.
      
avatar
Date: 2013-02-19 17:52
Posted By: Jonathan Parker (JPDabnis)

The following is a temp fix for the problem that I explained above:

Using the templateid param of cms_stylesheet as in : {cms_stylesheet
templateid='mb_dummy'}

Creating the template mb_dummy as a absolute minimal template , I can then
assign a set of css files that I want just for mobile devices to the mb_dummy
template, thus allowing me to write:

{if $device == 'MOBILE'}
{cms_stylesheet templateid='mb_dummy'}
{else}
{cms_stylesheet}  // This supplying the normal combined stylesheet associated
with this template.
{/if}

Jonathan
      
avatar
Date: 2013-02-20 15:36
Posted By: Jonathan Parker (JPDabnis)

Update to my temp fix above:
The templateid param of the cms_stylesheet tag takes an integer value NOT the
template name.
The template ID can be found as templateid= int within the admin url when
editing the template.

I can now confirm that the below works as expected.

{if $device == 'MOBILE'}
{cms_stylesheet templateid=32}  // 32 being the int id of the template named
'mb_dummy'
{else}
{cms_stylesheet}  // This supplying the normal combined stylesheet associated
with this template.
{/if}
      
avatar
Date: 2015-04-18 19:14
Posted By: Robert Campbell (calguy1000)

actually,  it is actually better to leave this up to the browser, and just
specify media queries for your stylesheets.

Then {cms_stylesheet} will merge the stylesheets as appropriate for the media
queries, and output the propery <link> tags.

the browser will then only load the stylesheets that are required.
      
Updates

Updated: 2013-01-31 11:33
resolution_id: => 6
assigned_to_id: 100 => 11306