Porting problem.....

Permalink
i am porting a theme into C5, but the theme requires some additional javascript which effects C5 when in edit mode

<script src="<?php echo $this->getThemePath()?>/script/jquery_cycle.js" type="text/javascript"></script>
   <script src="<?php echo $this->getThemePath()?>/script/bubblepopup.js" type="text/javascript" ></script>
   <script src="<?php echo $this->getThemePath()?>/script/ui_core.js" type="text/javascript"></script>
   <script src="<?php echo $this->getThemePath()?>/script/ui_tabs.js" type="text/javascript"></script>
   <script type="text/javascript">
   $(function() {
      $('#placeimages').cycle({ 
         fx:    'fade', 
         delay: 2000,
         timeout: 4000
      });
      $('#menutabs').tabs({ fx: { opacity: 'toggle' } });
   });
   </script>


how would i disable the javascript only when the page is in edit mode?

thanks in advance

salesman
 
defunct replied on at Permalink Reply
defunct
Hello,

Try this for including your scripts while not in edit mode

<?php  
global $c;  
if (!$c->isEditMode()) {  
// include javascript files
}  
?>


Cheers.
salesman replied on at Permalink Reply
salesman
it brings up an error

Parse error: parse error in C:\wamp\www\concrete\themes\web\default.php on line 21
defunct replied on at Permalink Reply
defunct
Parse error means you didn't properly write PHP code (didn't close a bracket, or use a semi-colon etc.)

Please post your full page code here.
salesman replied on at Permalink Reply 1 Attachment
salesman
I cant see what ive done wrong
defunct replied on at Permalink Reply
defunct
I don't see the if statement in this code?
salesman replied on at Permalink Reply 1 Attachment
salesman
take 2
defunct replied on at Permalink Reply
defunct
First you did not escape your code properly which is why you are getting php errors. You either need to stop the php with ?> or echo your script tags.

But I also gave you the wrong function, thanks Scottc.

<?php
if (!$this->editingEnabled()) {   ?>
        <script src="<?php echo $this->getThemePath()?>/script/jquery_cycle.js" type="text/javascript"></script>
        <script src="<?php echo $this->getThemePath()?>/script/bubblepopup.js" type="text/javascript" ></script>
        <script src="<?php echo $this->getThemePath()?>/script/ui_core.js" type="text/javascript"></script>
        <script src="<?php echo $this->getThemePath()?>/script/ui_tabs.js" type="text/javascript"></script>
        <script type="text/javascript">
        $(function() {
                $('#placeimages').cycle({
                        fx:    'fade',
                        delay: 2000,
                        timeout: 4000
                });
                $('#menutabs').tabs({ fx: { opacity: 'toggle' } });
        });


That will work for you.
salesman replied on at Permalink Reply
salesman
I have the code working it now reads

<?php
global $c;
if (!$c->isEditMode()) {   ?> 
        <script src="<?php echo $this->getThemePath()?>/script/jquery_cycle.js" type="text/javascript"></script> 
        <script src="<?php echo $this->getThemePath()?>/script/bubblepopup.js" type="text/javascript" ></script> 
        <script src="<?php echo $this->getThemePath()?>/script/ui_core.js" type="text/javascript"></script> 
        <script src="<?php echo $this->getThemePath()?>/script/ui_tabs.js" type="text/javascript"></script> 
        <script type="text/javascript"> 
        $(function() { 
                $('#placeimages').cycle({ 
                        fx:    'fade', 
                        delay: 2000, 
                        timeout: 4000 
                }); 
                $('#menutabs').tabs({ fx: { opacity: 'toggle' } });
defunct replied on at Permalink Reply
defunct
Glad you figured it. I guess the first solution was the right one :)

It wasn't working for me in the c5 beta version which is why I was trying to find another way to do it.