www.webdeveloper.com
Results 1 to 3 of 3

Thread: Need help for simple php syntax

Hybrid View

  1. #1
    Join Date
    Mar 2011
    Posts
    39

    Need help for simple php syntax

    hello

    I would like implement this trick on template of my joomla site:

    http://davidwalsh.name/prevent-cache

    My goal is to avoid to cache only one specific css file (template.css). I looked in my template and I found this code:

    PHP Code:
        <?php 
            $gantry
    ->displayHead();
            
    $gantry->addStyles(array('template.css','joomla.css'));
            
            if (
    $gantry->browser->platform != 'iphone')
                
    $gantry->addInlineScript('window.addEvent("domready", function(){ new SmoothScroll(); });');
                
            if (
    $gantry->get('loadtransition') && isBrowserCapable()){
                
    $gantry->addScript('load-transition.js');
                
    $hidden ' class="rt-hidden"';
            } else {
                
    $hidden '';
            }
            
        
    ?>

    So I modified the code like this:

    PHP Code:
        <?php 
            $gantry
    ->displayHead();
            
    $gantry->addStyles(array('template.css?<?php echo time(); ?>','joomla.css'));
            
            if (
    $gantry->browser->platform != 'iphone')
                
    $gantry->addInlineScript('window.addEvent("domready", function(){ new SmoothScroll(); });');
                
            if (
    $gantry->get('loadtransition') && isBrowserCapable()){
                
    $gantry->addScript('load-transition.js');
                
    $hidden ' class="rt-hidden"';
            } else {
                
    $hidden '';
            }
            
        
    ?>

    but the result is not rendered because in my page I see this:
    Code:
      <link rel="stylesheet" href="/templates/rt_clarion/css/template.css?<?php echo time(); ?>" type="text/css" />

    I suppose is because the php is not well modified and unfortunately I don't have php knowledge. I tried to play a bit with the code but without success.

    Somebody can help please ?

    many thank

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,245
    You are already in PHP mode at that point, so you just need to use some string concatenation:
    PHP Code:
        <?php 
            $gantry
    ->displayHead();
            
    $gantry->addStyles(array('template.css?' time(), 'joomla.css'));
            
            if (
    $gantry->browser->platform != 'iphone')
                
    $gantry->addInlineScript('window.addEvent("domready", function(){ new SmoothScroll(); });');
                
            if (
    $gantry->get('loadtransition') && isBrowserCapable()){
                
    $gantry->addScript('load-transition.js');
                
    $hidden ' class="rt-hidden"';
            } else {
                
    $hidden '';
            }
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Mar 2011
    Posts
    39
    you rock...this work well.

    many thank

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles