We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    Hi,

    I am using this snippet on the template of my blog page, so that I can display the first blog article as the home page - rather than users having to manually select the first article to read.

    [[!FirstChildRedirect]]
    


    My blog is powered by Articles.

    The only problem is that since using this, the TAGS in my sidebar (which are populated using the [[+tags]] placeholder from the standard Articles TPL) no longer work - instead of filtering my posts by tags, the redirect kicks in, and displays the first Child post.

    I assume this is due to the URLs for tags looking like this:

    http://www.domain.com/blog/?tag=sales

    Is there any way to prevent the [[!FirstChildRedirect]] kicking in if there is a query in the URL?

    Or, should I be redirecting from the blog page differently for the first article?

    Thanks
    Andy
      • 51020
      • 670 Posts
      UPDATE on this - it's also doing the same with [[+archives]] - so users can no longer view posts from 2016 etc.
        • 3749
        • 24,544 Posts
        You'd think, since it's a literal redirect ($modx->sendRedirect()), that the page would work and look as it always does (assuming that you show tags and archives on every blog article page).

        You might try changing sendRedirect() to sendForward() at the end of the FirstChildRedirect snippet. That will pull the child article's content into the blog home page.

        sendForward() needs an ID as an argument, so hard-code one to test it. If it works, you can re-write the code to get the first child's ID. I'm not sure it will work because I Articles has its own makeURL() function (which could be part of your problem).



          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 51020
          • 670 Posts
          Quote from: BobRay at May 24, 2017, 08:06 PM
          You'd think, since it's a literal redirect ($modx->sendRedirect()), that the page would work and look as it always does (assuming that you show tags and archives on every blog article page).

          You might try changing sendRedirect() to sendForward() at the end of the FirstChildRedirect snippet. That will pull the child article's content into the blog home page.

          sendForward() needs an ID as an argument, so hard-code one to test it. If it works, you can re-write the code to get the first child's ID. I'm not sure it will work because I Articles has its own makeURL() function (which could be part of your problem).




          OK thanks Bob - appreciate it.
          I think maybe I am over complicating things - I could just pull the entire first story into the home page of the blog using getResources in the template.

          I think maybe the redirect is a bit cumbersome.
            • 51020
            • 670 Posts
            UPDATE: I have changed my Articles container template, so that the first full article appears in this template - all good.
            I would like to use a different template for TAGS and ARCHIVE, but it seems I'm tied to using the Container template - is there a way around this where I can specify different templates?

            I've also ready that it's better to create blogs with collections rather than Articles so that it's less restrictive?
              • 17301
              • 932 Posts
              Articles support stopped some years ago so Collections is the standard nowadays.

              You should be able to use a different template for Tags and Archive though, but it's been a while since I've used Articles to comment with confidence.
                ■ email: [email protected] | ■ website: https://alienbuild.uk

                The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                • 3749
                • 24,544 Posts
                I'm still using Articles for my blog. So far, it's been very solid for me.

                I put the tags and archives at the end of each article.

                There are Tpl chunks for lots of the components (which you can replace with your own), but they're difficult to find.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 51020
                  • 670 Posts
                  Thanks for all the advice and feedback so far.
                  It seems the issue is probably nothing to do with the redirect, nor Articles.

                  I set up a new blog, using just Collections, Tags, and Archivist.
                  Again, the archive links don't work - all the archive links go to a 404 page.

                  For the archives I'm using this on my archives template page (resource 135):

                  [[!getPage?
                    &element=`getArchives`
                    &elementClass=`modSnippet`
                    &tpl=`BlogCollectionsRowTpl`
                    &hideContainers=`1`
                    &pageVarKey=`page`
                    &parents=`131`
                    &includeTVs=`1`
                    &toPlaceholder=`archives`
                    &limit=`10`
                    &cache=`0`
                  ]]
                  
                  [[+archives]]
                  
                  
                  


                  Then in the sidebar of all pages I'm using this to give me a list of available archives:

                                  [[!Archivist? &target=`135` &parents=`131`]]
                  


                  Resource 131 is my Blog container page.

                  If it click on any of the archive lines, the target URL looks as expected (domain.com/archives/2017/05/) but it just gives me a 404 error.


                  Any ideas what could cause this?

                  Thanks
                  Andy
                    • 3749
                    • 24,544 Posts
                    I'm not sure if this is helpful, but mine looks like this:

                    https://bobsguides.com/blog.html2016/12


                    blog.html is the URL of my blog container page.

                    You might try &target=`131`

                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 51020
                      • 670 Posts
                      Quote from: BobRay at May 26, 2017, 04:45 PM
                      I'm not sure if this is helpful, but mine looks like this:

                      https://bobsguides.com/blog.html2016/12


                      blog.html is the URL of my blog container page.

                      You might try &target=`131`


                      Thanks bob - I think you're right re the target - but I've actually redone the templates without articles now - quite impressed that it all comes together with collections, tags and archivist.