paulm2003 Posted January 10, 2004 Share Posted January 10, 2004 Normally when I use a named anchor tags like this: <a href="#tips">Jump to the Useful Tips Section</a> It jumps to the named tag <a name="tips">tips</a> on the same page. but in osCommerce for some reason it does not work, it only works if I use for example: <a href="faq.php#tips">Jump to the Useful Tips Section</a> Does anybody know why? :unsure: It seems to me that this last solution makes the whole page load again, which I obviously don't want to happen, only want it to jump to the named tag inside the current page. Quote Link to comment Share on other sites More sharing options...
jbretel Posted December 8, 2004 Share Posted December 8, 2004 Normally when I use a named anchor tags like this: <a href="#tips">Jump to the Useful Tips Section</a> It jumps to the named tag <a name="tips">tips</a> on the same page. but in osCommerce for some reason it does not work, it only works if I use for example: <a href="faq.php#tips">Jump to the Useful Tips Section</a> Does anybody know why? :unsure: It seems to me that this last solution makes the whole page load again, which I obviously don't want to happen, only want it to jump to the named tag inside the current page. <{POST_SNAPBACK}> QUOTE(Red3D @ Nov 27 2004, 07:04 PM) PHP pages are dynamic and will reload unlike static HTML files - but you must consider sessions when you code links in OSCommerce - see the following:- Hi this is a reply to another post but may help you, I have just sussed a fix for my site using ancor tags and also using the session ID in the header. use the echo tep_href_link like this to link to a page in the static information pages (there is a function to ref to product pages but I'm unsure if it will accept the following code:- <?php echo tep_href_link( "reference_rigs5.php"); ?>#spinning NOTE - add the #anchor tag outside the php echo tep_href_link code and this will maintain the session ID whilst providing an HTML style anchor to wherever on the page you want the link to point to ! (in this case "#spinning") In OSC sessions it merely adds it after the OSCid and maintains the session. I tried many things to get this to work, but if like me you have avoided using cookies etc then this definitely works ! I'll be watching this thread so any comments or problems please feed back ! Regards Jeremy :D Quote Link to comment Share on other sites More sharing options...
boxtel Posted December 8, 2004 Share Posted December 8, 2004 QUOTE(Red3D @ Nov 27 2004, 07:04 PM)PHP pages are dynamic and will reload unlike static HTML files - but you must consider sessions when you code links in OSCommerce - see the following:- Hi this is a reply to another post but may help you, I have just sussed a fix for my site using ancor tags and also using the session ID in the header. use the echo tep_href_link like this to link to a page in the static information pages (there is a function to ref to product pages but I'm unsure if it will accept the following code:- <?php echo tep_href_link( "reference_rigs5.php"); ?>#spinning NOTE - add the #anchor tag outside the php echo tep_href_link code and this will maintain the session ID whilst providing an HTML style anchor to wherever on the page you want the link to point to ! (in this case "#spinning") In OSC sessions it merely adds it after the OSCid and maintains the session. I tried many things to get this to work, but if like me you have avoided using cookies etc then this definitely works ! I'll be watching this thread so any comments or problems please feed back ! Regards Jeremy :D <{POST_SNAPBACK}> remove the <BASE HREF statement which is in every page. I had the same problem, removed it and voila ! Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted December 8, 2004 Share Posted December 8, 2004 remove the <BASE HREF statement which is in every page.Hmm.. stil not sure what the BASE HREF is good for, never used it before I entered the oscommerce world, but it might be there for a good reason. You can also work around this problem by using this: <a href="<?php echo $_SERVER['REQUEST_URI']; ?>#top">Top</a> Works like a normal anchor tag (so without reloading the whole page), the session is retained, and you can keep the BASE HREF. @Jeremy: using the tep_href the whole page is reloaded after every click, or isn't it? @Amanda: You remind me, I have got to work on my languages switch :D trilly and Demitry 2 Quote Link to comment Share on other sites More sharing options...
berkedam Posted December 8, 2004 Share Posted December 8, 2004 Easy, for instance in faq.php href: <a href="faq.php#1"> jumps to: <a name="1">whatever</a> Quote "If you're working on something new, then you are necessarily an amateur." Link to comment Share on other sites More sharing options...
Guest Posted December 8, 2004 Share Posted December 8, 2004 Easy, for instance in faq.php...... <{POST_SNAPBACK}> Hi John, sorry but the solution you propose here has already been mentioned at the top of this thread, but it does not work as we would like, because it makes the whole page reload!While one of the nice things about those anchors is, that it's not needed to reload the page. (Which saves me some bandwith and the customers some time) Quote Link to comment Share on other sites More sharing options...
berkedam Posted December 8, 2004 Share Posted December 8, 2004 Hi John, sorry but the solution you propose here has already been mentioned at the top of this thread, but it does not work as we would like, because it makes the whole page reload!While one of the nice things about those anchors is, that it's not needed to reload the page. (Which saves me some bandwith and the customers some time) <{POST_SNAPBACK}> Hi Paul,Oops I see I read to fast :) Anyway OP started with faq and I see no reason for a page called faq.php not to do it the way we both like, no reload is IMO good in that case :) Quote "If you're working on something new, then you are necessarily an amateur." Link to comment Share on other sites More sharing options...
Thomas_Burke Posted April 23, 2005 Share Posted April 23, 2005 Has anyone got any further suggestions on how to make anchors work properly, especially on dynamic pages where you can't just add the appropriate HTML. Obviously the session ID needs to be retained. Expalin it to me please, I'm a complete idiot when it comes to PHP. :-" Quote My contributions Link to comment Share on other sites More sharing options...
boxtel Posted April 24, 2005 Share Posted April 24, 2005 Has anyone got any further suggestions on how to make anchors work properly, especially on dynamic pages where you can't just add the appropriate HTML. Obviously the session ID needs to be retained. Expalin it to me please, I'm a complete idiot when it comes to PHP. :-" <{POST_SNAPBACK}> I use this function : add to html_output.php function tep_sp_link ($name) { // same page link global $request_type; if ($request_type == 'SSL') { $link = HTTPS_SERVER . DIR_WS_HTTP_CATALOG; } else { $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG; } $uri = str_replace('/','',getenv(REQUEST_URI)); return $link . $uri . '#' . $name; } then for the link I use : <td align="right"><a onmouseover="window.status='Top'; return true" href="<?php echo tep_sp_link('top'); ?>"><img src="images/button_top.gif" border="0" alt="top" title="top"></a></td> Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Thomas_Burke Posted May 2, 2005 Share Posted May 2, 2005 Thank you very much to boxtel for helping me out on this. Here are the important points she helped me with: boxtel: You cannot add php code to the product description in admin. ok, this should work : in html_output.php you add this new function : function tep_sp2_link () { global $request_type; if ($request_type == 'SSL') {$link = HTTPS_SERVER ;} else {$link = HTTP_SERVER ;} $uri = $_SERVER['REQUEST_URI']; return $link . $uri; } then in products_info.php you have this statement : echo stripslashes($product_info['products_description']); that statement puts your description on the page. just before that statement you add this : // start anchor same page link $anchor_link = tep_sp2_link(); $product_info['products_description'] = str_replace('[sp2link]', $anchor_link, $product_info['products_description']); // end anchor same page link this basically looks in your text to find the link [sp2link] and replaces that with the real page link including parameters and sid if present. then in your product description in your admin you write the links like this : See this link <a href="[sp2link]#top">for more information.</a> go to our <a href="[sp2link]#business">Business section</a> etc. You can ofcourse change the link to whatever you like for example *anchor* or @anchor as long as you make sure that that text does not appear in your normal text otherwise the program would replace that as well. so make it something that would normally not be in your product description. let me know if it works ok This all worked, thank you boxtel. :D Quote My contributions Link to comment Share on other sites More sharing options...
Thomas_Burke Posted May 2, 2005 Share Posted May 2, 2005 (edited) Thank you very much to boxtel for helping me out on this. Here are the important points she helped me with:This all worked, thank you boxtel.? :D <{POST_SNAPBACK}> Also, the Session IDs are retained. I have to make a slight change as I want the osCommerce files to be in the root directory not in the "catalog" directory. This is because Search Engines will give you a better position if the pages are closer to the root. :) Edited May 2, 2005 by Thomas_Burke Quote My contributions Link to comment Share on other sites More sharing options...
Informundo Posted June 6, 2005 Share Posted June 6, 2005 Also, the Session IDs are retained. I have to make a slight change as I want the osCommerce files to be in the root directory not in the "catalog" directory. This is because Search Engines will give you a better position if the pages are closer to the root. :) <{POST_SNAPBACK}> I installled the contribution Anchor Tag. This work fine, but i have the name of product or categorie in header.php and in footer.php. I want installed in this files and don?t work. I want adapt this contribution ?Can you help me? Thanks Tienda de informatica online. Venta de ordenadores. Venta de port?titles Quote Link to comment Share on other sites More sharing options...
Guest Posted August 24, 2005 Share Posted August 24, 2005 (edited) I use this function : add to html_output.php function tep_sp_link ($name) {? // same page link ? global $request_type; if ($request_type == 'SSL') { ? $link = HTTPS_SERVER . DIR_WS_HTTP_CATALOG; } else { ? $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG; } $uri = str_replace('/','',getenv(REQUEST_URI)); return $link . $uri . '#' . $name; } then for the link? I use : ? ? ? ? <td align="right"><a onmouseover="window.status='Top'; return true" href="<?php echo tep_sp_link('top'); ?>"><img src="images/button_top.gif" border="0" alt="top" title="top"></a></td> <{POST_SNAPBACK}> I just did a search for anchor tags and found this and it doesnt quite work properly because I think our store is in a directory and Boxtel`s isnt. Using the above gives us a reloaded page with a url similar to... www.oursite.com/shopshopcurrentpage.php (ie the shop directory seems to be doubled up) Ive tried playing about a bit but cant quite figure it out :blush: Can anyone be so kind to help me out please? Edited August 24, 2005 by Reesy Quote Link to comment Share on other sites More sharing options...
pixeljuice Posted August 29, 2005 Share Posted August 29, 2005 I adjusted the code in html_output.php and product_info.php as suggested above in this thread. I'd thought to be able to use it in my FAQ page, where topics at the top of the page link down to anchors further down on the same page. <a href="[sp2link]#Anchor-What-49575">What is included in your services?</a> takes me to a "404 Not Found" error page. I did add code to the faq.php page that is similar to the code added to the product_info.php page, with no change. Ideas? Quote Link to comment Share on other sites More sharing options...
Guest Posted August 30, 2005 Share Posted August 30, 2005 I adjusted the code in html_output.php and product_info.php as suggested above in this thread. I'd thought to be able to use it in my FAQ page, where topics at the top of the page link down to anchors further down on the same page. <a href="[sp2link]#Anchor-What-49575">What is included in your services?</a> takes me to a "404 Not Found" error page. I did add code to the faq.php page that is similar to the code added to the product_info.php page, with no change. Ideas? <{POST_SNAPBACK}> PandA.nl`s code workded for me Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 30, 2005 Share Posted August 30, 2005 I just did a search for anchor tags and found this and it doesnt quite work properly because I think our store is in a directory and Boxtel`s isnt.Using the above gives us a reloaded page with a url similar to... www.oursite.com/shopshopcurrentpage.php (ie the shop directory seems to be doubled up) Ive tried playing about a bit but cant quite figure it out :blush: Can anyone be so kind to help me out please? <{POST_SNAPBACK}> try this instead: $uri = substr(getenv(REQUEST_URI), 1); Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted August 30, 2005 Share Posted August 30, 2005 I adjusted the code in html_output.php and product_info.php as suggested above in this thread. I'd thought to be able to use it in my FAQ page, where topics at the top of the page link down to anchors further down on the same page. <a href="[sp2link]#Anchor-What-49575">What is included in your services?</a> takes me to a "404 Not Found" error page. I did add code to the faq.php page that is similar to the code added to the product_info.php page, with no change. Ideas? <{POST_SNAPBACK}> go to your faq page, view the source and check what the links look like. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
BuddahBoy Posted January 22, 2007 Share Posted January 22, 2007 Thanks for this nifty contrib - quick and easy, works like a charm greatly appreciate all the time and effort the community members put in and allow someone like me to get such great results with relative ease! That's what makes OSC so great. Quote Link to comment Share on other sites More sharing options...
BuddahBoy Posted July 16, 2007 Share Posted July 16, 2007 Greetings - these tags work great in the product pages - I'm also using Information pages - anybody got input on how to use them on these pages as well? Thanks much Ron Quote Link to comment Share on other sites More sharing options...
Guest Posted September 19, 2007 Share Posted September 19, 2007 Hi Guys, I really suck at php and just need to know how the actual code would look when adding this... then in products_info.php you have this statement : echo stripslashes($product_info['products_description']); that statement puts your description on the page. just before that statement you add this : // start anchor same page link $anchor_link = tep_sp2_link(); $product_info['products_description'] = str_replace('[sp2link]', $anchor_link, $product_info['products_description']); // end anchor same page link Quote Link to comment Share on other sites More sharing options...
motorcity Posted October 2, 2007 Share Posted October 2, 2007 Hi Guys,I really suck at php and just need to know how the actual code would look when adding this... then in products_info.php you have this statement : echo stripslashes($product_info['products_description']); that statement puts your description on the page. just before that statement you add this : // start anchor same page link $anchor_link = tep_sp2_link(); $product_info['products_description'] = str_replace('[sp2link]', $anchor_link, $product_info['products_description']); // end anchor same page link Well I just got here from Google on your code. Any idea how I can add chunks of text I'm importing in multiple fields? This has no errors shown, but still doesn't display products_description2. <p><?php echo stripslashes($product_info['products_description']); ?></p> <p><?php echo stripslashes($product_info['products_description2']); ?></p> Should I put both ['products_description''products_description2'] in the brackets? Quote Link to comment Share on other sites More sharing options...
trilly Posted October 29, 2010 Share Posted October 29, 2010 You can also work around this problem by using this: <a href="<?php echo $_SERVER['REQUEST_URI']; ?>#top">Top</a> Works like a normal anchor tag (so without reloading the whole page), the session is retained, and you can keep the BASE HREF. Thank you PandA.nl! I found this page through Google, and this was the simplest fix. Thanks for the help! Quote Link to comment Share on other sites More sharing options...
powerdrive Posted November 25, 2010 Share Posted November 25, 2010 (edited) Just installed and it changes the links as expected; <a href="[sp2link]#whatever">Link</a> does give longfile.php#whatever but then it says 'file not found' when clicked. I tried <p id="#whatever> and <a name="whatever">, am I doing it wrong?? Can anyone explain how to get it working on categories pages too? I looked through index.php but can't see what to change. Edited November 25, 2010 by powerdrive Quote Link to comment Share on other sites More sharing options...
techhouse Posted September 2, 2015 Share Posted September 2, 2015 Hmm.. stil not sure what the BASE HREF is good for, never used it before I entered the oscommerce world, but it might be there for a good reason. You can also work around this problem by using this: <a href="<?php echo $_SERVER['REQUEST_URI']; ?>#top">Top</a> That works perfectly! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.