dongtiaobeng7901 2015-03-06 20:53
浏览 44
已采纳

使用PHP条件和Metamod仅在特定URL上显示joomla模块

I need to show modules only on pages which url contains "saucony". For example show product slider only on pages like: /sneakers/woman-sneakers-saucony-dxn-trainer-black-orange-detail or /sneakers/woman-sneakers-saucony-jazz-low-pro-vegan. There are a lot of urls with random names, so i cant put all of them into condition directly by hand using full URL path with REQUEST_URI for each product. I try to use

    if ($_SERVER['REQUEST_URI'] == "-saucony"){
$vm = JomGenius("virtuemart"); 
$cat = $vm->info("category_id"); 
if ($cat and $vm->check("pagetype startswith productdetails") ) { 
  $changes->mod(192) 
  ->setParam("virtuemart_category_id",$cat) 
  ->title("Products: " . $vm->info("category_name")) 
  ->showTitle(true); 
  return 192; 
}
}
  • 写回答

1条回答 默认 最新

  • duankuang1046 2015-03-07 02:02
    关注

    Currently your outer if statement is checking if the full URL path is completely equal to "-saucony"; it should be checking if the full URL path only contains "-saucony". Use strpos to search for a containing string element.

    if (strpos($_SERVER["REQUEST_URI"],"-saucony") !== false) 
    {
            // code to load product slider
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀