BoldMinded acquires Ansel, support ending for all add-ons. BoldMinded acquires Ansel, support ending for all add-ons. Read More →
Support has been discontinued. Issues remain available as an archive. Support has been discontinued. Issues remain available as an archive.
Creating Sitemap with Construct
#44 opened by DJ Hughes
Description
Is there an easy way to create a sitemap with Construct? I have a site where client can add Generic Pages and place them wherever they want within the Construct Tree. How would I create a dynamic sitemap.xml that would pull all pages?
Replies
- TJ Draper
Replied 9/1/2017 11:55 AM, Edited 9/5/2017 11:46 AM
I think you'd be looking for the
nested="false"
parameter on thenodes
tag pair so you could output everything in a flat tag loop.{exp:construct:nodes tree_id="2" nested="false"} {!-- Sitemap Code Stuff --} {/exp:construct:nodes}
- DJ Hughes
Replied 9/1/2017 12:17 PM, Edited 9/5/2017 11:46 AM
ok that seemed to give me all the top level pages from within Construct... so after that I'd just have to add channel:entries to get all the pages from entries I'm guessing.
One question, how would I get the <lastmod> for all those pages from Construct? I tried this but it didn't work http://prntscr.com/gfwk65
- TJ Draper
Replied 9/1/2017 12:23 PM, Edited 9/5/2017 11:46 AM
The construct nodes tag does not provide any info from the entry (like edit_date). You'd need to use the channel entries tag for that and provide it the node_entry_id. If you're just getting the entry date from the entry, you might want to try Last Edit Edit as it would be a much lighter query than the Channel Entries tag for every node:
https://buzzingpixel.com/software/last-edit-date/documentation/template-tag
I thought the
nested="false"
parameter should provide all nodes from the tree as if they were top level nodes, but I might be mis-remembering how I wrote that. If it's not, you could just do something like:{exp:construct:nodes tree_id="1"} <url> <loc>{site_url}{construct:node_link}</loc> </url> {construct:children} {/exp:construct:nodes}
- DJ Hughes
Replied 9/1/2017 1:21 PM, Edited 9/5/2017 11:46 AM
sorry, nested="false" does provide all subpages as well. that works.
- DJ Hughes
Replied 9/1/2017 1:32 PM, Edited 9/5/2017 11:46 AM
I installed Last Edit... but the dates don't seem correct. seems like entry has todays date but the Times are different. I know i didn't edit all those entries today so something don't seem right.
2017-09-01T14:24:54-04:00
{exp:last_edit_date
channel_id="{construct:node_entry_id}" format="{DATE_W3C}" status="open" show_future_entries="true"
}
- TJ Draper
Replied 9/1/2017 5:21 PM, Edited 9/5/2017 11:46 AM
You're using the
channel_id
parameter on the Last Edit Date tag. You'll want to use theentry_id
parameter. - DJ Hughes
Replied 9/1/2017 5:53 PM, Edited 9/5/2017 11:46 AM
doh! gracias