• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: What is a direct link to a stylesheet?
PostPosted: Fri Apr 13, 2012 5:06 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Dec 23, 2008 8:39 pm
Posts: 1316
Augustas wrote:
mcDavid wrote:
I think using the old stylesheet.php file for this would actually be a very good solution.


But using this old file does not guarantee that with the next CMSMS update this old stylesheet.php code will work. Looking to the long-run, I think best would be to avoid old version codes.


If you upgrade a site, this stays, and still works.. I believe that if they end up finding a security issue, the next upgrade release would delete this file, and remove the {stylesheet} tag.

Using the static file wouldn't work, because this gets re-generated using a temp name if the CSS changes.


Top
 Profile  
 
 Post subject: Re: What is a direct link to a stylesheet?
PostPosted: Thu Jul 05, 2012 6:05 am 
Offline
New Member

Joined: Thu Jul 05, 2012 5:52 am
Posts: 1
Well in my opinion I don't think you can link directly becoz the Style sheet code is in the database and then compile and temporarily cached in the 'temp/cache' directory.


Top
 Profile  
 
 Post subject: Re: What is a direct link to a stylesheet?
PostPosted: Thu Jul 05, 2012 11:49 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Aug 12, 2008 9:30 pm
Posts: 1979
Location: Feldkirchen in Kärnten, Austria
If extrenal system that is going to be used supports PHP then it is fairly easy to do it.

Step 1:
Create new template in your CMSMS, for example simply named "Blank"
And simply call only stylesheet in there:
Code:
{strip}{content assign='foo'}{cms_stylesheet nolinks=1}{/strip}


Save that Template.

Step 2:
Attach stylesheets you want to use to newly created Template or edit cms_stylesheet tag in step one to include stylesheet with parameter name=

Step 3:
Create new page in your CMSMS and apply your newly created template to that page.
Hide it from menu and save it.

Output of that page would be for example:
Quote:
"http://yourdomain.com/tmp/cache/stylesheet_combined_MD5_stuff.css


Step 4:
Make sure that this page isn't being indexed or something, so edit your robots.txt or well it's up to you :)

Step 5:
Now simply add few lines of PHP:
Code:
<?php
$url = file_get_contents('http://yourdomain.com/index.php?page=WHATEVER_YOUR_ALIAS_IS'); // url to page to read content from
$data = file_get_contents(trim($url)); // if that page has only one url read that content
$file = md5(serialize($url)) . '.css'; // filename
$cache_file = './cache/' . $file; // cached file and folder

if (!file_exists($cache_file) || filemtime($cache_file) < (time() - 3600)) {
    if (!file_exists($cache_file)) {
        mkdir('./cache', 0777);
    }
    file_put_contents($cache_file, $data);
    chmod($cache_file, 0664);
    $html = '<link rel="stylesheet" href="cache/' . $file . '" type="text/css" />';
} else {
    $html = '<link rel="stylesheet" href="cache/' . $file . '" type="text/css" />';
}
echo $html;
?>


Thats it, the output would be:
Code:
<link rel="stylesheet" href="cache/74324b7a7dc71e971e07e8fc3869d8b1.css" type="text/css" />


Basically what was done is reading content of your created page, then reading content of url that we have as content in that page.
After that is done a file is saved in "cache" folder.
If saved file is older then one hour it will be resaved again.

_________________
CMSMS Blog - I do this!
Forge profile
Github profile
Twitter
=============================================
Support CMSMS


Top
 Profile  
 
 Post subject: Re: What is a direct link to a stylesheet?
PostPosted: Thu Jul 05, 2012 2:04 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 6576
Location: Fernie British Columbia, Canada
Sorry goran, but slightly faster, and simpler solution would be:

a: create a new template with:
Code:
{strip}{content assign='junk'}{cms_stylesheet}{/strip}


b: create a new page using that template,
b.1 mark it as not shown in menu
b.2 give it a custom alias like: 'stylesheets' (or use a custom url)
b.3 make sure that it isn't being indexed in the robots.txt etc.

c: in your other application (i.e: wordpress) php code would be something similar to:
Code:
    $url = 'http://the/complete/url/to/page/created/in/stepb';
    $cachefile = '/tmp/website_stylesheet.cache';  // pick any unique filename and writable location
    if( !file_exists($cachefile) || filemtime($cachefile) < time() - 3600 ) {
       file_put_contents($cachefile,file_get_contents($url));
    }
    echo file_get_contents($cachefile);

_________________
Follow me on twitter
--
if you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: What is a direct link to a stylesheet?
PostPosted: Thu Jul 05, 2012 2:08 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Aug 12, 2008 9:30 pm
Posts: 1979
Location: Feldkirchen in Kärnten, Austria
Cool :) thx
Just a proof that there is nothing like "can't be done" with cmsms ;D

_________________
CMSMS Blog - I do this!
Forge profile
Github profile
Twitter
=============================================
Support CMSMS


Top
 Profile  
 
 Post subject: Re: What is a direct link to a stylesheet?
PostPosted: Thu Jul 05, 2012 9:31 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Oct 17, 2007 6:09 pm
Posts: 232
Location: the world
That's a great idea! Thank you - this is what I was looking for.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner