Recommended Posts

@Mike Rockett It seems as if I'm unable to include images in the sitemap. Besides that, the module is working just fine. I can find the option to exclude images (page-based) but neither the one to include them, nor do they get included automatically. I'm using only one images field in my template and the page is multilingual. Any hints what I'm doing wrong?

Thanks.

Share this post


Link to post
Share on other sites

Hi @rash -- did you add the image field in via the module's config? This is basically a way to globally add specific image fields in one swoop, and then the exclusion options are available at page-level to override.

Share this post


Link to post
Share on other sites

@Mike Rockett This is the way I would have assumed to go, unfortunately I can't find an option like the one you describe. On the module’s config page there are the following sections:

Module information
Templates with sitemap options
Templates without sitemap options
ISO code for default languages
Stylesheet
Support Development
Deinstall

Either I’m suffering from vision defects, or the mentioned option is missing.  (Or carefully hidden.)


 

Share this post


Link to post
Share on other sites

@rash, the module checks to see if any image fields are available to your installation. To be more precise, the check is specific to FieldtypeImage, which might be where the problem is coming in... I'm not sure if there are other Image modules that extend FieldtypeImage out there (and if so, if you're using one). On my side though, a fresh install of PW with the latest MarkupSitemap and an image field added in results in the config showing the applicable selector:

image.thumb.png.12d3036fa66f579e804a117047785c38.png

  • Like 1

Share this post


Link to post
Share on other sites

@Mike Rockett Thanks for your fast reply. It looks as if we’re getting closer: my images are of fieldtype CroppableImage3, resulting from the popular module with the same name. Do you think I could just change the field type where the check happens? Or extend the range of possible field types? I’m no big fan of module hacks, but in this case I could live with it. Would you mind to reveal the exact check location?

Update: I’ve got the job done now – much easier than expected. Just in case somebody faces the same problem: in /site/modules/MarkupSitemap/MarkupSitemapConfig.php in line 90 I changed

if ($imageFields = $this->fields->find('type=FieldtypeImage') and $imageFields->count) {

to

if ($imageFields = $this->fields->find('type=FieldtypeImage|FieldtypeCroppableImage3') and $imageFields->count) {

to extend the range of considered field types. The option select appeared and everything works perfectly now. Another thanks for your help.

  • Thanks 1

Share this post


Link to post
Share on other sites
3 hours ago, Mike Rockett said:

I've bumped to 0.4.0 RC3 on the repo.

@Mike Rockett Fine, thank you. Just a question for future generations: As I presume that there are (or will be) several different images field types, wouldn’t it be better to keep the check more generic? The way I’ve suggested is working for me, but has the big drawback that every single field type must be explicitely listed – and you might never catch all of them. So is there a syntax for (in plain words) find('type=fields that are somehow managing images')?

Share this post


Link to post
Share on other sites

@rash You're quite right. I did think about it earlier, but not 100% sure how to go about it... Would be awesome if we could do something like find('extends=FieldtypeImage').

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, Mike Rockett said:

Would be awesome if we could do something like find('extends=FieldtypeImage')

The next best thing...

$imageFields = [];
foreach($this->fields as $field) {
   if($field->type instanceof FieldtypeImage) $imageFields[] = $field;
}

 

Edited by Robin S
Forgot the ->type
  • Like 1

Share this post


Link to post
Share on other sites

Hi @Mike Rockett

Thanks for this module! I was just looking at the module settings and noticed that there is an array of setting for every page of the site that has been saved since this module was installed. Any chance you could not add the:

"o1029":{
"priority":false,
"excludes":{
"images":false,
"page":false,
"children":false
}
}

for each page, unless one of the options is true?

Otherwise on a large site over time, this is going to become huuuge! And especially given that for most pages, I doubt anyone is touching these settings.

Thanks!

Share this post


Link to post
Share on other sites

Sorry @Mike Rockett - another question for you. What do you think about supporting the finding of pages that are children of hidden / unpublished pages? Just because a parent isn't viewable doesn't mean the children aren't.

Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

I've updated in the modules directory.
Don't have time at the moment to look at this – if its needed urgently, please submit a merge request. 🙂

  • Like 2

Share this post


Link to post
Share on other sites

Thanks @Mike Rockett for the fix to prevent saving of unnecessary settings - that will be a huge improvement.

Regarding the hidden/unpublished parents preventing children from appearing in the sitemap, isn't it simply a matter of adding include=all to the children() selector on this line: https://gitlab.com/rockettpw/seo/markup-sitemap/blob/142c86571aca9cb80569398b94d69a73676272b9/src/Traits/BuilderTrait.php#L190

 

Share this post


Link to post
Share on other sites
Posted (edited)

Deleted, see below.

Edited by Nick Belane
Didn't use the quote as below

Share this post


Link to post
Share on other sites
On 3/29/2018 at 10:30 AM, maxf5 said:

I am using the module on various multilingual sites and it's working fine!

When you have Jumplinks installed it sometimes hits an 404 on /sitemap.xml even though the link/sitemap is working.
Do you have to create an extra page and template  (xml header) for it?
 

I have the same "issue".
sitemap.xml is working properly but throws a 404 in jumplinks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Marco Angeli
      Hi there,
      I added a ssl certificate to my site and I'd like to redirect every single http url to its new https version
      So I added this code in the .htacces file, after the RewriteEngine On :
      Redirect 301 /about https://www.mysite.it/about
      Unfortunately this is now working: I get the "too many redirects" error.
      The following code works, but it's a bulk redirection to the home page, something I don't want for SEO reasons (https://moz.com/blog/save-your-website-with-redirects😞
      RewriteCond %{HTTP_HOST} mysite\.it [NC]
      RewriteCond %{SERVER_PORT} 80
      RewriteRule ^(.*)$ https://www.mysite.it/$1 [R,L]
      Any suggestions?
    • By gebeer
      Hi,
      just wanted to share something I came across while working on an import module for XML data from a web service. The XML I got was not huge, but still, loading around 3.5 MB of XML with 250+ large child nodes into memory at once with simplexml_load_file() and then looping over it had significant impact on performance.
      I searched for a solution and found this great article about how to parse large XML files.
      It basically explains how to utilize the native XMLReader class together with SimpleXMLElement to handle such situations in a memory efficient way.
      After implementing it I got a significant improval on perceived performance. No comparison in numbers to share here as I'm a bit short on time.
    • By chrizz
      hey there
      I guess a lot of you have already heard of the hreflang attribute which tells search engines which URL they should list on their result pages. For some of my projects I build this manually but now I am wondering if there's need to add this as a module to PW modules directory. 
      How do you deal with the hreflang thingy? Would you you be happy if you can use a module for this or do you have concerns that using a module maybe does not cover your current use cases?
      Cheers,
      Chris
       
       
       
       
    • By FrancisChung
      Hi, I have an ongoing issue with Google SEO that I can't seem to fix. Wondering if anyone has come across a similar situation?

      We deployed a new version of the website using a new deployment methodology and unfortunately, the wrong robots.txt file was deployed basically telling Googlebot not to scrape the site.

      The end result is that if our target keywords are used for a (Google) search, our website is displayed on the search page with "No information is available for this page." 

      Google provides a link to fix this situation on the search listing, but so far everything I have tried in it hasn't fixed the situation.
      I was wondering if anyone has gone through this scenario and what was the steps to remedy it?
      Or perhaps it has worked and I have misunderstood how it works?

      The steps I have tried in the Google Webmaster Tool :
      Gone through all crawl errors Restored the Robots.txt file and Verified with Robots.txt tester Fetch/Fetch and Render as Google as both Desktop/Mobile, using root URL and other URLs, using Indexing Requested / Indexing Requested for URL and Linked Pages. Uploaded a new Sitemap.xml  Particularly on the Sitemap page, it says 584 submitted, 94 indexed.
       
      Would the Search Engine return "No Information available" because the page is not indexed? The pages I'm searching for are our 2 most popular keywords and entry points into site. It's also one of 2 most popular category pages.  So I'm thinking it probably isn't the case but ...

      How can I prove / disprove the category pages are being indexed?

      The site in questions is Sprachspielspass.de. The keywords to search are fingerspiele and kindergedichte.

       
    • By John W.
      SYNOPSIS
      A little guide to generating an sitemap.xml using (I believe) a script Ryan originally wrote with the addition of being able to optionally exclude child pages from being output in the sitemap.xml file.
      I was looking back on a small project today where I was using a php script to generate an xml file, I believe the original was written by Ryan. Anyway, I needed a quick fix for the script to allow me to optionally exclude children of pages from being included in the sitemap.xml output.
      OVERVIEW
      A good example of this is a site where if you visit /minutes/ a page displays a list of board meetings which includes a title,  date, description and link to download the .pdf file.
      I have a template called minutes and a template called minutes-document. The first page, minutes, when loaded via /minutes/ simply grabs all of its child pages and outputs the name, description and actual path of an uploaded .pdf file for a visitor to download.
      In my back-end I have the template MINUTES and MINUTES-DOCUMENT. Thus:


      So, basically, their employee can login, hover over minutes, click new, then create a new (child) record and name it the date of the meeting e.g. June 3rd, 2016 :

       
      ---------------------------
      OPTIONALLY EXCLUDING CHILDREN - SETUP
      Outputting the sitemap.xml and optionally excluding children that belong to a template.
      The setup of the original script is as follows:
      1. Save the file to the templates folder as sitemap.xml.php
      2. Create a template called sitemap-xml and use the sitemap.xml.php file.
      3. Create a page called sitemap.xml using the sitemap-xml template
       
      Now, with that done you will need to make only a couple of slight modifications that will allow the script to exclude children of a template from output to the sitemap.xml
      1. Create a new checkbox field and name it:   sitemap_exclude_children
      2. Add the field to a template that you want to control whether the children are included/excluded from the sitemap. In my example I added it to my "minutes" template.
      3. Next, go to a page that uses a template with the field you added above. In my case, "MINUTES"
      4. Enable the checkbox to exclude children, leave it unchecked to include children.
      For example, in my MINUTES page I enabled the checkbox and now when /sitemap.xml is loaded the children for the MINUTES do not appear in the file.

       
      A SIMPLE CONDITIONAL TO CHECK THE "sitemap_exclude_children" VALUE
      This was a pretty easy modification to an existing script, adding only one line. I just figure there may be others out there using this script with the same needs.
      I simply inserted the if condition as the first line in the function:
      function renderSitemapChildren(Page $page) { if($page->sitemap_exclude_children) return ""; ... ... ...  
      THE FULL SCRIPT WITH MODIFICATION
      <?php /** * ProcessWire Template to power a sitemap.xml * * 1. Copy this file to /site/templates/sitemap-xml.php * 2. Add the new template from the admin. * Under the "URLs" section, set it to NOT use trailing slashes. * 3. Create a new page at the root level, use your sitemap-xml template * and name the page "sitemap.xml". * * Note: hidden pages (and their children) are excluded from the sitemap. * If you have hidden pages that you want to be included, you can do so * by specifying the ID or path to them in an array sent to the * renderSiteMapXML() method at the bottom of this file. For instance: * * echo renderSiteMapXML(array('/hidden/page/', '/another/hidden/page/')); * * patch to prevent pages from including children in the sitemap when a field is checked / johnwarrenllc.com * 1. create a checkbox field named sitemap_exclude_children * 2. add the field to the parent template(s) you plan to use * 3. when a new page is create with this template, checking the field will prevent its children from being included in the sitemap.xml output */ function renderSitemapPage(Page $page) { return "\n<url>" . "\n\t<loc>" . $page->httpUrl . "</loc>" . "\n\t<lastmod>" . date("Y-m-d", $page->modified) . "</lastmod>" . "\n</url>"; } function renderSitemapChildren(Page $page) { if($page->sitemap_exclude_children) return ""; /* Aded to exclude CHILDREN if field is checked */ $out = ''; $newParents = new PageArray(); $children = $page->children; foreach($children as $child) { $out .= renderSitemapPage($child); if($child->numChildren) $newParents->add($child); else wire('pages')->uncache($child); } foreach($newParents as $newParent) { $out .= renderSitemapChildren($newParent); wire('pages')->uncache($newParent); } return $out; } function renderSitemapXML(array $paths = array()) { $out = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; array_unshift($paths, '/'); // prepend homepage foreach($paths as $path) { $page = wire('pages')->get($path); if(!$page->id) continue; $out .= renderSitemapPage($page); if($page->numChildren) { $out .= renderSitemapChildren($page); } } $out .= "\n</urlset>"; return $out; } header("Content-Type: text/xml"); echo renderSitemapXML(); // Example: echo renderSitemapXML(array('/hidden/page/'));  
      In conclusion, I have used a couple different processwire sitemap generating modules. But for my needs, the above script is fast and easy to setup/modify.
      - Thanks