We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 52128
    • 29 Posts
    On Followthecamino.com we have the search button, it is working for all pages except for any blog on our website. We are using: articles-1.7.11-pl extra.

    For example, if i have search for "Exchange rate" and click on "Exchange Rate Leads to Huge Savings" it link to this page: https://www.followthecamino.com/exchange-rate-leads-to-huge-savings2 which doesnt exiast so it link to 404 page. It should be linking to https://www.followthecamino.com/blog/2016/02/12/exchange-rate-leads-to-huge-savings2/


    See the seach result code below...

    <?php
    if(isset($_POST['phrase'])&&$_POST['phrase']!=null){
    $i=0;
    	//searching in content
    	$pPhrase = strtolower(addslashes($_POST['phrase']));
    
    	
    	//searching in products
    	$pQuery = "SELECT p.product_id,d.value as name,d2.value as description, p.alias FROM ftc_products p INNER JOIN ftc_dictionary d ON d.record_id=p.product_id INNER JOIN ftc_dictionary d2 ON d2.record_id=p.product_id WHERE d.type='product' AND d.language_id=1 AND d.field='name' AND d2.type='product' AND d2.language_id=1 AND d2.field='description' AND (  lower(d.value) like '%".$pPhrase."%' OR lower(d2.value) like '%".$pPhrase."%') ";
    	
    	$pRes = $modx->query($pQuery);
    	while($pRow = $pRes->fetch()){
    		?><li><h2><?php echo stripslashes($pRow['name']);?></h2><p><?php echo substr(strip_tags(stripslashes($pRow['description'])),0,150);?> <a href="/<?php echo "trip/".$pRow['alias'];?>" style="color:#8C1E05;" > more »</a></p></li><?php
    		$i++;
    	}//while
    	
    	$pQuery = "SELECT c.id,c.alias, d.value as content, d2.value as pagetitle FROM ftc_site_content c LEFT JOIN ftc_dictionary d ON d.record_id=c.id LEFT JOIN ftc_dictionary d2 ON d2.record_id=c.id WHERE d.type='content' AND d.field='content' AND d.language_id=1 AND d2.type='content' AND d2.field='pagetitle' AND d2.language_id=1 AND (  lower(d.value) like '%".$pPhrase."%' OR lower(d2.value) like '%".$pPhrase."%' )";
    	
    	$pRes = $modx->query($pQuery);
    	while($pRow = $pRes->fetch()){
    		?><li><h2><?php echo stripslashes($pRow['pagetitle']);?></h2><p><?php echo substr(strip_tags(stripslashes($pRow['content'])),0,150);?> <a href="<?php echo $modx->makeUrl($pRow['id']);?>" style="color:#8C1E05;"> more »</a></p></li><?php
    		$i++;
    	}//while
    	
    	
    	//search in blog
    	$pQuery = "SELECT * FROM ftc_site_content  WHERE published=1 AND parent=348 AND (lower(pagetitle) like '%".$pPhrase."%' OR lower(content) like '%".$pPhrase."%') ORDER BY publishedon DESC ";
    	
    	$pRes = $modx->query($pQuery);
    	while($pRow = $pRes->fetch()){
    		?><li><h2><?php echo stripslashes($pRow['pagetitle']);?></h2><p><?php echo substr(strip_tags(stripslashes($pRow['content'])),0,150);?> <a href="<?php echo $pRow['alias'];?>" style="color:#8C1E05;"> more »</a></p></li><?php
    		$i++;
    	}//while
    	
    	/*
    	//searching in categories
    	$pQuery = "SELECT n.news_id, n.insert_date, d.value as title, d2.value as content FROM ftc_news n INNER JOIN ftc_dictionary d ON d.record_id=n.news_id INNER JOIN ftc_dictionary d2 ON d2.record_id=n.news_id WHERE d.language_id=1 AND d.type='news' AND d.field='title' AND d2.type='news' AND d2.field='content' AND ( lower(d.value) like '%".$pPhrase."%' OR lower(d2.value) like '%".$pPhrase."%' )";
    	$pRes = $modx->query($pQuery);
    	while($pRow = $pRes->fetch()){
    		?><li><h2><?php echo stripslashes($pRow['title']);?></h2><p><?php echo substr(strip_tags(stripslashes($pRow['content'])),0,150);?> <a href="/<?php echo link_konwert($pRow['title']);?>-news<?php echo $pRow['news_id'];?>.html" style="color:#8C1E05;"> more »</a></p></li><?php
    		$i++;
    	}//while
    	*/
    	
    	
    	
    	
    	if($i==0){
    		?><p><strong>No search results.</strong></p><?php
    	}
    }else{
    		?><p><strong>No search results.</strong></p><?php
    }//if
    ?>
    </ul>


    Any help is greatly appreciated.

    Many thanks

    Gail

    This question has been answered by magzzs. See the first response.

      • 3749
      • 24,544 Posts
      Are you sure the article is published? I've seen a similar problem when I forget to publish the Article.
        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
        • 52128
        • 29 Posts
        Yes I am 100% sure it is published, the problem is, it is not including the /blog/*Date*/ in the URL.

        Any ideas?

        Thanks

        Gail
          • 3749
          • 24,544 Posts
          The Articles plugin is attached to OnPageNotFound. Based on the end of the URL (which is the article's actual alias), the Articles router finds the article, constructs the URL, and redirects to it.

          Search is finding the article and then using its actual alias to create the link to it. I don't know why the page can't be found that way. I notice that it can't on my blog either.

          I think it might be possible to alter the Search Tpl to send the href to a custom snippet as an argument. The snippet would retrieve the resource, and if it's not a Blog article, just return the href. If it is an article, the snippet could use the publishedon field and transform the href into the correct form and return that for display in the search results.

          There may be a much easier solution, but I don't know of one.

          FWIW, I use the Google search box on my site and it does produce the proper URLs:

          https://www.google.com/search?domains=bobsguides.com&q=the+modx+config+files&sa=Google+Search&sitesearch=bobsguides.com&client=pub-6359507128964525&forid=1&ie=UTF-8&oe=UTF-8&cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%23FDEFD2%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3A669999%3BLBGC%3A669999%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BFORID%3A1&hl=en


            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
            • 52128
            • 29 Posts
            Thanks Bob, Hopefully I will find a way to fix this.

            • discuss.answer
              • 52128
              • 29 Posts
              I have use the paid version of google search on the website. it is working well and very happy with it. Thanks Bob for your help

              Magz