codeigniter reveal modal load once per session/cookie - php

I have a modal window that loads on index page using the following command,
data-reveal-onready="Register"
$(document).ready(function () {
$('[data-reveal-onready]').reveal();
});
I want to add a php if statement on the data-reveal-onready to load only once per session on the homepage and when the user visits the homepage again it will not appear on load.
The modal is a registration form so obviously the modal window may be needed again and it will still show when clicking on register button.
I am using codeigniter and reveal modal.
Many thanks

Perhaps use CI's session class?
// Initialize on visit
$this->session->set_userdata('register_pop_up', true);
// Check
if ($this->session->userdata('register_pop_up'))
{
// Don't display in the future
$this->session->unset_userdata('register_pop_up');
}

You could also use cookies to set the modal window. That way if a user comes to your site, gets the modal window, leaves and comes back before the cookie expiration, they will not get the modal window again.
http://ellislab.com/codeigniter/user-guide/helpers/cookie_helper.html

Related

SSO Login without Page refresh

I need to know how I can process the SSO login without reloading the page.
My sample link is http://abmprograms.com/tdr/disqus.php
When I click on the first option to login a pop-up opens, if I either try to login with below details (see my comment below) or close it the page reloads.
Is there anyway to prevent this?
Looks like you are using, jquery. Have you tried using modal forms: http://jqueryui.com/dialog/#modal-form
You can control the login form post using javascript which would let you control the modal form behavior.

close modal after submit of form on redirect to same page

I have a form inside a modal that automatically opens on load. the form submits the time to a database when it is activated which starts a timer to evaluate how long it takes a participant to complete a task on the page. The page redirects to itself when the submit button is clicked as the events to be measured are on the opening screen. However when the page is reloaded the modal opens once again. How would I stop the modal from opening again on the submit of the form and reloading of the page? I have everything working but this part. I am using basic jquery. Nothing fancy.
Add destination url for your link. Get more help from below urls:
https://drupal.stackexchange.com/questions/66707/how-to-redirect-to-another-page-after-submitting-the-ctools-modal-form/108040#108040
https://drupal.stackexchange.com/questions/29157/redirect-form-out-of-modal-window-after-submit/108039#108039
You could redirect to the same page with an added query string value that stops the modal from being displayed.

Php use header location to load new page in entire window within jquery tabs

I use Jquery tabs with in each tab a form. If the form is submitted it’s reloaded (after the actions in the database) in the tab so that not the whole page has to be reloaded. One of the forms has to link to a payment page if there has to be payed, so after some checks after a submit the payment page has to be loaded and the current page has to close. But if I use header-location the entire page Is loaded in the tab and i don’t want that….
Ho to use header-location from within the tab and load the payment page in the entire window (from PHP and not from Javascript because I can’t do the checks and vallidations)….
Use iframes or check out the jQuery $.ajax() method
You can use
echo "<script>
window.location='?action=';
</script>";

Running jQuery command from modal window to affect main page

I'm currently trying to write a jQuery script which opens a modal box then (upon user entry) changes a value on the original page.
Currently I've got the script working on just the page itself (without the modal), but when I try to run the command from the modal the value on the main page doesn't change?
Does anyone know how I can solve this?
Thanks,
Tom
Make a function in the page itself (not the modal sub-page), then call opener.myMethod() in the modal sub-page.
If the modal dialog is using an iframe, then from within the iframe you can do either of the following (depending on whether you have nested iframes or whatnot).
window.parent.myMethod();
top.myMethod();
And to access elements on the main page you could do this (assuming you have jquery included on the main page as well):
top.$('#myDiv').html('hello world');
Hope this helps.

posting variables between windows in php

my title may not be clear. But basically what I want to do is:
There will be a link in my php form
<a href="somepage.php" target=_blank>Update</a>
when the user clicks on the link, a new browser window opens and allows him to select some options. There will be close button in that window. When he clicks on that 'close' button, there is a post form from where the parent window should get the selected value.
When I get that selected value from that child browser window, how I am going to refresh parent browser window to reflect what user has selected in child window?
Environment : PHP
Can anyone give me some idea?
As far as I know you can't refresh a parent window using PHP (or, more correctly, pure HTML). You will need a bit of Javascript in your onLoad event:
window.opener.location.reload(); // Refresh
- or -
window.opener.location.href = "targetpage.php"; // Redirect
You would be able to refresh a child window that was opened before from that page using a named target:
<a href="new_window.php" target="my_new_window_i'm_going_to_refresh">
(apostrphe for demonstration purposes only :)
repeated clicking on that link should refresh the child every time. It doesn't work the other way round, though.
In parent expect the refreshed values something like as:
parent.php?value=xxx
on popup, when user clicks close, you can always use window.opener.location = "parent.php?value=XXX" ... this will refresh the parent with the value selected.

Categories