[SOLVED] Deactivate/Active popup window (jQuery)

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
User avatar
fearmydesign
Power Poster
Power Poster
Posts: 363
Joined: Sun Feb 28, 2010 10:54 pm

[SOLVED] Deactivate/Active popup window (jQuery)

Post by fearmydesign »

??? Hello, I currently have a popup window when someone first logs into the site - http://www.stjuderockville.com/index.php - that comes up, and I created a content page which shows on this window. But I want to be able to disable/enble this popup using the Active option on CMSMS Pages.

Currenlty if I set the Active to False, it still shows the popup window with a message that says "The requested content cannot be loaded. Please try again later."

Here is the code that calls this popup window on my home template:

Code: Select all

{php}
if($_COOKIE['school']!='test')
{
    setcookie("school", "test");
    
{/php}
<div id="inline1" href="{cms_selflink href='popup-window'}"></div>
{php} } 
{/php}
and this is the Script in the head section

Code: Select all

{literal}
<__script__ type="text/javascript" src="fancybox/jquery.fancybox-1.3.4.pack.js"></__script>
   
<__script__ type="text/javascript">
    $(document).ready(function() {
        $("#inline1").fancybox({'height':400}).trigger('click');
        $("#inline1").fancybox({'width':500}).trigger('click');
		
    });
</__script>
{/literal}
I guess the question qould be how do I check to see if that page is active or not, and if it isn't, then to ignore the popup window code I guess. Any guidance will be greatly appreciated - I am not a developer, but I try really hard to figure this stuff out... thanks
Last edited by fearmydesign on Sat Mar 03, 2012 9:31 pm, edited 2 times in total.
User avatar
fearmydesign
Power Poster
Power Poster
Posts: 363
Joined: Sun Feb 28, 2010 10:54 pm

Re: Deactivate/Active popup window (jQuery)

Post by fearmydesign »

I tried several {if} statement options, but I can't seem to get it to work... I don't know how to make it recognize if the page is active or not, and if its not active to do nothing and just show the regular home page instead of the popup

Code: Select all

{if $page_alias == "popup-window"}

{else}
    <div id="inline1" href="{cms_selflink href='popup-window'}"></div>
{/if}
hope someone can help, thanks
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

Re: Deactivate/Active popup window (jQuery)

Post by applejack »

You will probably have to write a UDT which queries the cms_content table and whether or not the active column is set to 1 or 0.

Not sure why you need this. If it is just a case of making it easy for a client to switch it on and off the you could just create 2 templates for the home page 1 with the popup one without and then the edit the home page and change the template whenever they wish.
User avatar
fearmydesign
Power Poster
Power Poster
Posts: 363
Joined: Sun Feb 28, 2010 10:54 pm

Re: Deactivate/Active popup window (jQuery)

Post by fearmydesign »

applejack wrote:You will probably have to write a UDT which queries the cms_content table and whether or not the active column is set to 1 or 0.

Not sure why you need this. If it is just a case of making it easy for a client to switch it on and off the you could just create 2 templates for the home page 1 with the popup one without and then the edit the home page and change the template whenever they wish.
Thanks... that's just it, I want to make it super easy for the client to turn on/off without too much. I have no idea what an UDT is, but I think I will post an offer on the appropriate forum for someone to help me build this. Thanks for your help
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Deactivate/Active popup window (jQuery)

Post by Dr.CSS »

UDT is a user defined tag which uses PHP, just like you first post where you have {php}...

I'm still not sure what you are trying to do with the pop up...
User avatar
fearmydesign
Power Poster
Power Poster
Posts: 363
Joined: Sun Feb 28, 2010 10:54 pm

Re: Deactivate/Active popup window (jQuery)

Post by fearmydesign »

Dr.CSS wrote:UDT is a user defined tag which uses PHP, just like you first post where you have {php}...

I'm still not sure what you are trying to do with the pop up...
Thank you for the info, and sorry about the vague explanation... its really a very simple concept...
I want the client to be able to enable or disable the 'Popup Window' when you first go to the website. This would allow them to display special event information when there is one.

The trick is that I want them to be able to enable or disable the popup 'using the Activate option' under pages, which you can set to 'true' or 'false'.

Hope this makes sense. Thank you
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Deactivate/Active popup window (jQuery)

Post by Dr.CSS »

Now I see, you want to turn it on/off using the page active/inactive setting on the "pop up" page, well it won't show the page but you will still get the little loading image, I would do something in the Home page to turn it on/off like a oneline text field, {if !empty(oneline text box)} the code to make pop up {else} {/if}...
User avatar
fearmydesign
Power Poster
Power Poster
Posts: 363
Joined: Sun Feb 28, 2010 10:54 pm

Re: Deactivate/Active popup window (jQuery)

Post by fearmydesign »

So I had Applejack work on this small project for me, and I just wanted to share in case this is useful to anybody else. This makes it very simple for the client to turn on/off a Popup window on the home page of the site that can be used to display 'special events', 'Inclement Weather', 'School Closings' etc. - simply by clicking the Active column under Content/Pages (set to true or false).

This code goes in the <head> section:

Code: Select all

{active mypage="popup-window"}
{if $activestatus == 1}
<!--  I am active -->
<__script__ type="text/javascript" src="fancybox/jquery.fancybox-1.3.4.pack.js"></__script>
{literal}
<__script__ type="text/javascript">
    $(document).ready(function() {
        $("#inline1").fancybox({'height':400}).trigger('click');
        $("#inline1").fancybox({'width':500}).trigger('click');
		
    });
</__script>
{/literal}

<link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox-1.3.4.css" media="screen" />
{else}
<!--  I am not active -->
{/if}
And this code goes in your </__body>:

Code: Select all

<!-- POP UP -->
{php}
if($_COOKIE['school']!='test')
{
    setcookie("school", "test");
    
{/php}
<div id="inline1" href="{cms_selflink href='popup-window'}"></div>
{php} } 
{/php}
<!-- POP UP -->
And this is the code that goes into the actual User Defined Tags under Extensions:

Code: Select all

if(isset($params['mypage'])) {
      $mypage = $params['mypage'];
}

$gCms = cmsms();
$db = cmsms()->GetDb();

$q = mysql_query("SELECT active from ".cms_db_prefix()."content WHERE content_alias='".$mypage."'");

$status = mysql_fetch_assoc($q);
$smarty->assign('activestatus',$status['active']);
Post Reply

Return to “Layout and Design (CSS & HTML)”