user tip Custom Module Pages in Sitemap

PatriaCo
PatriaCo
@the-patria-company
6 years ago
349 posts
How can I ensure that pages created using a module's index.php are included in the sitemap?


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3

updated by @the-patria-company: 04/14/19 10:04:53PM
paul
@paul
6 years ago
4,325 posts
All 'datastore' modules' index pages are included by default when creating site maps.
If the module isn't a 'datastore' module, or if you want to include other module pages, the module will need to listen for the ''sitemap_site_pages'' event and add them to that.
hth


--
Paul Asher - JR Developer and System Import Specialist
PatriaCo
PatriaCo
@the-patria-company
6 years ago
349 posts
Ok, I'm still a module novice, so let me give this a try. Since my module does not have a schema.php it is NOT a datastore module. Correct? If that is the case I need to add the listener to the include.php? What should that line of code look like exactly?

jrCore_sitemap_site_pages ('jrCore', 'something', 'myCustomModule', 'enabled')

I feel like I am off in left field on this one. ;)

Thanks for your help.


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3
paul
@paul
6 years ago
4,325 posts
If no schema then likely not a datastore module.
Checkout this document on Events and Listeners - https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/1011/events-and-listeners
hth


--
Paul Asher - JR Developer and System Import Specialist
PatriaCo
PatriaCo
@the-patria-company
6 years ago
349 posts
Three words: Jamroom IS Awesome!!

We start with the includes.php and make sure that there is a listener registered and coded properly:

function myCustomModule_init(){
    // Add pages to sitemap
    jrCore_register_event_listener('jrSitemap', 'sitemap_site_pages', 'myCustomModule_sitemap_site_pages_listener')
    
    return true;
}

function myCustomModule_sitemap_site_pages_listener($_data, $_user, $_conf, $_args, $event)
{ $url = jrCore_get_module_url('myCustomModule'); $_data[] = "{$_conf['jrCore_base_url']}/{$url}/my-custom-module-page"; return $_data; }

Now, because we all want to meet the strictest SEO standards, make sure that your custom page in your module has hyphens in the URL (and NOT underscores) add this page view function to your index.php like this:

function view_myCustomModule_default($_post, $_user, $_conf)
{ switch ($_post['option']) { case'my-custom-module-page': return jrCore_parse_template('my-custom-module-page.tpl', $_rep, 'myCustomModule'); break; } }

And "Voila!" you now have a custom page, SEO ready and entered in your sitemap!


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3

Tags