PHP |当前页面 URI 切换器 | “分页”

发布于 2024-12-24 16:14:55 字数 820 浏览 1 评论 0原文

视觉

我正在尝试为同一产品的不同型号制作快速页面切换器。如果必须单独完成,这将很难实现,因此我使用一些 PHP 来实现。

每个产品的所有模型都有一个文件夹,问题是对它们进行正确排序,每个页面都已创建。每个型号在产品文件夹内都有自己的文件夹,并以数字结尾。

它们都属于两种类型的 URI

../product-name/###../product-name/title-###

所以我正在尝试编写一个 PHP 脚本,该脚本将采用当前页面的 URI 的 ###、下一个最低/最高的 ###,并将它们设置为 href 对于任一箭头。

如果没有下一个最低/最高的###,则将箭头透明度设置为0(如果需要,可以使用class来完成。

当前页面 code> 将填充当前页面的 </code>

有人至少能指出我正确的方向吗?非常感谢任何和所有帮助!

更新:感谢@gumbo,我现在知道这称为分页,如果有人知道至少与此非常相似的预构建脚本,请告诉我,谢谢!!

PS:我最终会将所有内容转移到 WordPress,所以如果这会让事情变得更容易,那么我就会等待。

Visual

I'm attempting to make a quick page switcher for different models of the same product. This would be hard to implement if it had to be done individually, so I'm making it with some PHP.

There is a single folder with all the Models for each product, the problem is correctly sorting them, the pages are already created with each one. Each model has its own folder inside of the product folder and ends with a number.

They all fall within two types of URI's

../product-name/### or ../product-name/title-###

So I'm trying to write a PHP script that would take the current page's URI's ###, the next lowest/highest ###, and set them as the href for either arrow.

If there is no next lowest/highest ### then set the arrow transparency to 0 (can be done with a class if necessary.

The Current Page would fill with the current page's <title>

Can someone at least point me in the right direction? Any and all help is greatly appreciated!

UPDATE: Thanks to @gumbo I now know that this is called pagination, if anyone knows of a Pre-built script that works at least very similar to this please let me know, THANKS!!

PS: I'm eventually moving everything over to wordpress, so if that would make it much easier then I'll just wait.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扛起拖把扫天下 2024-12-31 16:14:55

如果我理解正确的话,您希望访问目录的内容并对文件进行排序。

<?php
$dir_handle = opendir('./');

while ($file = readdir($dir_handle)) {

if ($file != "." && $file != "..") {?>

<span><?php echo $file?></span><br />

<?php }
}
closedir($dir_handle);
?>

这应该给你一个开始。使用基本名称($_SERVER['SCRIPT_NAME']);检索当前脚本的名称。也许下一步是提取当前脚本的 ### 并用针对每个文件的测试替换上面示例中的 span 元素。

If I understand correctly, you'd like to access the contents of a directory and sort through the files.

<?php
$dir_handle = opendir('./');

while ($file = readdir($dir_handle)) {

if ($file != "." && $file != "..") {?>

<span><?php echo $file?></span><br />

<?php }
}
closedir($dir_handle);
?>

That should give you a start. Use basename($_SERVER['SCRIPT_NAME']); to retrieve the name of the current script. Perhaps the next step would be to extract that current script's ### and replace the span element in the above example with a test against each file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文