How can you use php to call the current product page's url and use it within a link?
for example to do something like this:
<a href="<?php CURRENT PAGE ?>">clicky</a>
How can you use php to call the current product page's url and use it within a link?
for example to do something like this:
<a href="<?php CURRENT PAGE ?>">clicky</a>
<?php echo $_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI']; ?>
Believe it or not But My existence is illusional
Thanks!
I had to change it to <?php echo $_SERVER['REQUEST_URI']; ?> to get it to work because it was pulling up the root url twice then like http://site.comhttp://site.comhttp:/.../category/blah
Is this a standard php call? I always though zencart had a way of doing it too, like zen_url something something.
The function within the Zen Cart infrastructure is called zen_href_link.
If the product you're looking at is 5, for example, you would use
<a href="<?php echo zen_href_link(zen_get_info_page(5), "&products_id=5"); ?>">Some anchor text</a>
If you're on the product info page and you want the product id you're looking at, it's in
(int)$_GET['products_id']
(but if you're on the product page for a specific product, why do you need another URL to the product page for that product?)
That Software Guy. My Store: Zen Cart Modifications
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.
So is your *real* question actually about how to properly create a named anchor link within a page? There are numerous threads on that topic.
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
... and indeed, such a link should not use the current page information.
Read <a href="#more">more here</a> ...
...
<a name="more"></a>
Here's more ....
That Software Guy. My Store: Zen Cart Modifications
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.
I know that it works, but you're going back to the server for another page throw when you don't need to. The last way I suggested will be faster since it happens entirely in the browser.
That Software Guy. My Store: Zen Cart Modifications
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.
Just because it can work doesn't mean it's the best way to do it. The full URL would break if you made a test copy of your site elsewhere. The name anchor link would still work fine.
Bookmarks