Log in

View Full Version : Check if link has been clicked and do php on a called div



Rodrigo8
12-17-2014, 11:13 PM
Hello.
I'll introduce the problem i'm having in my way of designing a wordpress theme.
I want a youtube iframe to start loading when a link has been clicked (not before). For that, i've managed to find the next code:



<a href="?link=1" name="link1">link 1</a>

<div id="mainSection">
<?php
$link=$_GET['link'];
if ($link == '1'){
echo 'youtube iframe';
}
?>
</div>


This prints "youtube iframe" into the div "mainSection" when the link is clicked. It is very similar to what i want to do. This is okay, but i want that the a href calls an special div (with #) in which the youtube iframe will be loaded.
It would be like this:




<a href="#modal<?php echo get_the_ID(); ?>?link=1" name="link1">link 1</a>

<div id="modal<?php echo get_the_ID(); ?>" class="modalmask">
<div id="mainSection">
<?php
$link=$_GET['link'];
if ($link == '1'){
echo 'youtube iframe';
}
?>
</div>
</div>


On the a href, "#modal<?php echo get_the_ID(); ?>" is the div id adress that this link is calling (note that i've added the php to get the id of the respective post). So, this will be displayed on the called div. That's ok. But the problem is that with the addition of the div id "#modal<?php echo get_the_ID(); ?>" the php script stops recognizing the "?link=1" and therefore it no longer echoes anything. Even more specific, when i add the # character (#?link=1) it does not work.
¿How can i do this?