Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2020
    Posts
    226
    Plugin Contributions
    1

    Default redirect issues, href anchors not working

    Hi folks, hoping someone can help me with a bit of guidance. I had a page with anchor points for my privacy policy. It was generated by a legal documents site based on my answers to a questionnaire and then gave me some html that simply worked without issues. it uses anchor points... however, zencart misunderstands them now and redirects to the home page instead of conveniently scrolling them to the relevant section. At some point between them initially being drafted 3 years ago and the anchor points working fine something must have changed as last night i realised they no longer work as expected when moving them over to my test site. I checked on the live site and they no longer function there either which is zen 1.57 series.

    I've been trying to investigate it myself and seems it may be something to do with seo urls module and the way it generates said pages url? I tried to get a fix from chatgpt but it gave me an answer that was sort of great but a bit vague. it basically said that i should use java to create a listener that will correctly handle the link if it has a href anchor point. It also advised me it could likely cause issues and i should check if unsure... I was unsure at "java" the java it gave me is as follows...

    Code:
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault();
            const targetId = this.getAttribute('href');
            const targetElement = document.querySelector(targetId);
            if (targetElement) {
                targetElement.scrollIntoView({
                    behavior: 'smooth',
                    block: 'start'
                });
            }
        });
    });
    My thought is that potentially something previously existed which did this in zen which was removed or it was edited out for a reason im unaware of during the module dev that i've had done last year for a custom qr ticketing and event admissions module?

  2. #2
    Join Date
    Nov 2007
    Location
    Woodbine, Georgia, United States
    Posts
    4,019
    Plugin Contributions
    61

    Default Re: redirect issues, href anchors not working

    I think we'll need a link =) When you initially implemented it there should have been a js part of the integration. Do you still have the old site files?

    ~Melanie
    PRO-Webs, Inc. :: Recent Zen Cart Projects :: Zen Cart SEO – 12 Steps to Success
    **I answer questions in the forum, private messages are NOT answered. You are welcome to contact us via our website for professional engagements.

  3. #3
    Join Date
    Nov 2020
    Posts
    226
    Plugin Contributions
    1

    Default Re: redirect issues, href anchors not working

    Quote Originally Posted by mprough View Post
    I think we'll need a link =) When you initially implemented it there should have been a js part of the integration. Do you still have the old site files?

    ~Melanie
    My apologies, tired and trying to resolve small issues late into the night whilst my usual developer was busy with seasonal things and other clients emergencies and getting forgetful to include that key point, the page is at...

    Code:
    https://testing.crazygamer.uk/index.php?main_page=page&id=9
    on the home page as the privacy notice link at the moment. I never inserted javascript before, so no idea where id find the relevant file. I just created the ez page with the provided html from the website and it just simply worked as expected at the time of checking when first added to the live site 3 years ago.

    My usual dev has just replied today to one of a few emails and mentioned the issue with a brief glance could be the url rewriter or a couple of other things, so i'm hopeful it will be resolved. 3 years ago is a long time to think back to try and recall what came first in regards to creating that page and adding seo urls.

    I suspect its seo urls though that was most likely setup a few days after i'd actually created and tested that particular page though and i never thought to check that page still functioned as expected... :s

  4. #4
    Join Date
    Nov 2007
    Location
    Woodbine, Georgia, United States
    Posts
    4,019
    Plugin Contributions
    61

    Default Re: redirect issues, href anchors not working

    You will need to edit the code for the anchors to work with your bootstrap template. Here are some docs https://getbootstrap.com/2.3.1/components.html

    ~Melanie
    PRO-Webs, Inc. :: Recent Zen Cart Projects :: Zen Cart SEO – 12 Steps to Success
    **I answer questions in the forum, private messages are NOT answered. You are welcome to contact us via our website for professional engagements.

  5. #5
    Join Date
    Nov 2020
    Posts
    226
    Plugin Contributions
    1

    Default Re: redirect issues, href anchors not working

    thankyou melanie, i got a bit sidetracked with another project element and just spotted the email notification. it Definetly sounds like a job for the to do list, it has apparently been like that for a while on my live site and never been mentioned to me by a customer. the contents of the page is still legally worded which is the main thing for now. i think it might take me a late night hour when i can concentrate and a strong coffee for that one.

    i'm currently trying to squeeze out a new music event marketing/engagement module. i'm either an hour or so away from having a finished module ready to style and test or debug with drumroll... "battle of the bands for zen v1.0"

    I just hope my expectations and the result of the code align on testing, wish me luck... lol

  6. #6
    Join Date
    Nov 2020
    Posts
    226
    Plugin Contributions
    1

    Default Re: redirect issues, href anchors not working

    resolved!

    I added the full url of the ezpage to the front of one of the links after looking at it less tired and it worked so i sent it to notepad and used find next to quickly find all "href=" where it had an anchor and added the url front part to replicate the fix across the full page...

    sadly my battle of the bands module, although not throwing errors when installed on my second test site... it refuses to load up with the link in the admin panel, it seems to take a few moments to decide it can't be bothered and gives me a http 503. if i try to access the pages that are supposed to be viewable on the main module page by typing the url into the browser i get a http 500. my hour or so turned into 3 days, so it's safe to say i'm frustrated lol

 

 

Similar Threads

  1. Named Anchors Not Working?
    By tracstev in forum General Questions
    Replies: 13
    Last Post: 16 Feb 2011, 07:12 AM
  2. Page Not Found redirect not working for some of my deleted products
    By all4coffee in forum All Other Contributions/Addons
    Replies: 5
    Last Post: 16 Aug 2010, 12:58 AM
  3. Replies: 8
    Last Post: 3 Jul 2010, 02:53 AM
  4. Base HREF https issues
    By mikebackhouse in forum General Questions
    Replies: 38
    Last Post: 27 May 2009, 05:12 PM
  5. javascript questions for href redirect
    By KimberleyB in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 30 Oct 2006, 02:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR