Adding and removing javascript in c5 header
Permalink 1 user found helpful
Hi All
I have been trying to use this code that I have found in the forums
to turn off javascript when c5 is in EditMode
As you can see by the code I have added, it does not work.
Am I missing somthing ?
The code will say in my header "EditMode" when it is on
and "NOT EditMode" when it is off
Any help with this appreciated
regards
Albert
I have been trying to use this code that I have found in the forums
to turn off javascript when c5 is in EditMode
As you can see by the code I have added, it does not work.
Am I missing somthing ?
The code will say in my header "EditMode" when it is on
and "NOT EditMode" when it is off
Any help with this appreciated
regards
Albert
Hi TheRealSean
thank you for the reply.
I tryed it
It still does not work.
When the EditMode is on I would like to turn off my javascript's that are in the Header while I am editing the page.
My javascript's that is not part of the core stuff
regards
Albert
thank you for the reply.
I tryed it
It still does not work.
When the EditMode is on I would like to turn off my javascript's that are in the Header while I am editing the page.
My javascript's that is not part of the core stuff
regards
Albert
Hmm that should work, can you post an example or the site link?
you might have caught my post before the edit my initial post missed out the () at the end of isEditMode it is a function so should be
$c->isEditMode()
you might have caught my post before the edit my initial post missed out the () at the end of isEditMode it is a function so should be
$c->isEditMode()
Im stumped then this code works?, can you share a link or your code there must be something on your page that is preventing it from working.
If you do not want to post the site link here pm me and Ill take a look
If you do not want to post the site link here pm me and Ill take a look
Hi TheRealSean
the template that I am testing it on is from here
http://www.concrete5.org/marketplace/themes/yosemite/...
All I have done so fare is to add the code to the header.php file
regards
Albert
the template that I am testing it on is from here
http://www.concrete5.org/marketplace/themes/yosemite/...
All I have done so fare is to add the code to the header.php file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- Design by Free CSS Templateshttp://www.freecsstemplates.org... Released for free under a Creative Commons Attribution 2.5 License Name : Yosemite Description: A two-column, fixed-width design with dark color scheme. Version : 1.0 Released : 20091106 Modified for Concrete5 by Jordan Lev -http://jordanlev.com --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <base href="http://ftp3.dns-systems.net/~awddemo/concrete5/"> <?php Loader::element('header_required'); ?>
Viewing 15 lines of 47 lines. View entire code block.
regards
Albert
Ok try this one instead, to have it displayed when logged in not just in edit mode.
$u = new User();
$g = Group::getByName('Administrators');
$p = new Permissions($c);
if($u->isSuperUser()||$u->inGroup($g)){
//do stuff if logged in but may not be able to edit the page
//you could also check to see if they are allowed to edit,
if($p->canWrite()){
//logged in and can edit the page
}
}
I have sort of mixed the content from here
http://www.concrete5.org/documentation/how-tos/developers/administr...
and also here
http://www.concrete5.org/documentation/developers/permissions/conte...
Hopefully that should help you out now,
Regards
$u = new User();
$g = Group::getByName('Administrators');
$p = new Permissions($c);
if($u->isSuperUser()||$u->inGroup($g)){
//do stuff if logged in but may not be able to edit the page
//you could also check to see if they are allowed to edit,
if($p->canWrite()){
//logged in and can edit the page
}
}
I have sort of mixed the content from here
http://www.concrete5.org/documentation/how-tos/developers/administr...
and also here
http://www.concrete5.org/documentation/developers/permissions/conte...
Hopefully that should help you out now,
Regards
Hi TheRealSean
Thank you for the code. Eureka it works.
So what this code does is, when you login to C5 to
edit your site it can turn off code in the C5 site.
It's great if you have code conflicting with C5 when you are in
Edit mode.
you can also do it this way too
This code works only when you click "Edit Page" when you are in C5 and loged in
regards
Albert
Thank you for the code. Eureka it works.
So what this code does is, when you login to C5 to
edit your site it can turn off code in the C5 site.
It's great if you have code conflicting with C5 when you are in
Edit mode.
you can also do it this way too
<?php $u = new User(); $g = Group::getByName('Administrators'); $p = new Permissions($c); if($u->isSuperUser()||$u->inGroup($g)){ ?> "EditMode" <?php } else { ?> "NOT EditMode" <?php } ?>
This code works only when you click "Edit Page" when you are in C5 and loged in
regards
Albert
This is another way to have conditional code for when the edit tool bar is visible:
I'm not sure how this compares to checking if the user is in the administrators group so I thought I should add it.
Cheers
<?php $c = Page::getCurrentPage(); $cp = new Permissions($c); if (is_object($cp) && ($cp->canWrite() || $cp->canAddSubContent() || $cp->canAdminPage())) { ?> <!-- DO STUFF WHEN EDIT BAR IS VISIBLE --> <?php } ?>
I'm not sure how this compares to checking if the user is in the administrators group so I thought I should add it.
Cheers
This was really helpful, thanks! Just using canWrite() was good enough for my purposes.
$c = Page::getCurrentPage();
Also you have
Javascript is core to the functioning of Concrete so you wont be able to turn off javascript during edit mode and still have the page work.
You can use the code to prevent custom css from being loaded in though. I assume this is what you mean?