?
Solved

Coldfusion - show or hide bootstrap modal

Posted on 2015-02-04
4
Medium Priority
?
292 Views
Last Modified: 2016-02-25
I want to show a "register" modal window on my site after  a certain number of page views lets say 3 page views.

Currently, I have the "register" modal setup to be shown at page load unless the user is loggedin, in which case the modal will not be shown.

What I need help with is how to delay showing the "register" modal until the user has viewed more than 3 pages?

Thanks.
0
Comment
Question by:Bang-O-Matic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 40589068
Why not use a session variable to count the page views (only count if the user is not logged in), then when you get to count 3, you can set the display to visible.   In fact, you don't even need the code to be on the page before the third page view... so just include the code on page view 3
0
 

Author Comment

by:Bang-O-Matic
ID: 40589202
Hi gdemaria,

Could you give me a code example to work from?

Thanks for the help!
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 2000 total points
ID: 40589253
These two lines of code in your application.cfm / .cfc file will count the number of page views for that user's session

<cfparam name="session.PageCount" default="0">   <!--- this will create a session variable if it does not exist  --->

<cfset session.pageCount = val(session.pageCount) + 1>  <!--- increment the page count ---->


Then on your page, you can test to see if the number is 3 and in this case, I am showing how you can test for page view 3 or page view 10 or any other.

<cfif val(session.pageCount) eq 3 or val(session.pageCount) eq 10>

    (Put your code here to display the thing you want to display)

</cfif>


Since you also wanted to be sure the user was not logged in, you need to add a test for that..

<cfif NOT val(session.user_id) and val(session.pageCount) eq 3 or val(session.pageCount) eq 10>

    (Put your code here to display the thing you want to display)

</cfif>
0
 

Author Closing Comment

by:Bang-O-Matic
ID: 40589420
Thanks gdemaria! that worked out great.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question