简体   繁体   English

如果URL中存在锚标记,则为php,如果/ else,则更改一个php代码

[英]php if anchor tag is present in URL then change a php code if / else

I am working on a website that i just uploaded to a test area. 我正在一个刚上传到测试区域的网站上工作。

http://cascarinosonline.com.216-70-85-163.messtudios.com/ http://cascarinosonline.com.216-70-85-163.messtudios.com/

I want to edit the gallery based on an incoming link. 我想根据传入链接编辑图库。 Currently I am using supersized jquery pluggin for the gallery. 目前,我正在为画廊使用超大型jquery插件。

When you view the gallery now its working as it should, however when you are on the Homepage and you click on "new outside area" on the bottom right corner I want it the link to take you to the gallery page but start on a different slide. 当您现在查看图库时,它应该可以正常工作,但是当您在主页上并单击右下角的“新外部区域”时,我希望它的链接将您带到图库页面,但从另一个页面开始滑动。

I couldn't find an easy way to do this with supersized jquery plugin... I thought it would be a simple URL anchor tag like so: 我找不到使用超大jquery插件执行此操作的简单方法...我认为这将是一个简单的URL锚标记,如下所示:

http://cascarinosonline.com.216-70-85-163.messtudios.com/gallery.php#slide12 http://cascarinosonline.com.216-70-85-163.messtudios.com/gallery.php#slide12


So I think this is my solution, the default gallery page is labeled with a php value: 所以我认为这是我的解决方案,默认的图库页面标有php值:

<?php $page = "gallery" ; ?>

And in my code it says 在我的代码中

<?php if ($page == "gallery" ) { echo $galleryAll; } ?>

$galleryAll; $ galleryAll; has the list of gallery images in the normal order..... 具有正常顺序的图库图像列表.....


Now, I made a different php code that is: 现在,我制作了一个不同的php代码,即:

<?php if ($page == "galleryfix" ) { echo $galleryOutside; } ?>

Now this $galleryOutside; 现在这个$ galleryOutside; has the outside image first in the list. 外部图像在列表中排名第一。

Both examples above work, if I manually change the php page value to equal the content I want. 如果我手动将php页面值更改为等于我想要的内容,则以上两个示例均有效。

My Questions is: 我的问题是:

I added an anchor tag to the homepage link and it looks like this: 我在首页链接中添加了一个锚标记,它看起来像这样:

http://cascarinosonline.com.216-70-85-163.messtudios.com/gallery.php#outside

I want php to find the url and if it has "#outside" then echo $page == "galleryOutside" else $page == "gallery" 我想让php查找网址,如果它具有“ #outside”,则回显$ page ==“ galleryOutside”否则$ page ==“ gallery”

I am not sure if this is the best way to do this, but Im pretty positive it will work as long as you can use php to get the incoming link url and change if/else value. 我不确定这是否是最好的方法,但我很肯定,只要您可以使用php获取传入的链接网址并更改if / else值,它就会起作用。

Thanks in advance! 提前致谢! -O -O

UPDATE: I found this, but not working. 更新:我找到了,但是没有用。

<?php 

$host = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if($host == 'cascarinosonline.com.216-70-85-163.messtudios.com/gallery.php#outside') 
{
$page = "gallery";
}
else
{
$page = "galleryfix";
}

;?>

I ditched the php method, and used jquery to find the hash tag and to take the proper action inside the gallery. 我放弃了php方法,并使用jquery查找hash标签并在图库中采取适当的措施。

    if (window.location.hash == "#outside") {       
        $(".slide-11").addClass("activeslide");
    }   

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM