solved Create Basic Info Page in Module

PatriaCo
PatriaCo
@the-patria-company
6 years ago
349 posts
WHAT I WANT TO DO:

I am trying to create a new page in a module, similar to the way it is possible in a skin.

WHERE I AM STUCK:

I think I understand that I need to use an index.php view pointed to the tpl file in the module. So I have a template "alabama-plumbers.tpl" in my custom module.

Here is my function in the index.php in the module:
function view_pcTradesPlumbers_alabama_plumbers($_post, $_user, $_conf)
{ return jrCore_parse_template('alabama-plumbers.tpl', $_rep, 'pcTradesPlumbers'); }

PROBLEM: I am getting a "page not found"

OTHER INFO:
I am using a module URL (for SEO) of, "residential-commercial-plumbers"

Here is the link to my dev site URL that I am trying to get to work:

https://dev.patriaco.net/residential-commercial-plumbers/alabama-plumbers


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

updated by @the-patria-company: 01/18/19 07:20:32AM
michael
@michael
6 years ago
7,714 posts
_

--
Is that enough of a clue?

A: You're view function is view_pcTradesPlumbers_alabama_plumbers() but you're trying to access the page at alabama-plumbers.

your page is visible at:

https://dev.patriaco.net/residential-commercial-plumbers/alabama_plumbers

Well done.
PatriaCo
PatriaCo
@the-patria-company
6 years ago
349 posts
THANKS!!


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3
PatriaCo
PatriaCo
@the-patria-company
6 years ago
349 posts
Reading further, there is apparently still a negative effect on SEO when using the underscore in the URL title.
https://www.woorank.com/en/blog/underscores-in-urls-why-are-they-not-recommended

Is it possible to rewrite the URL to use a hyphen?

I tried
view_pcTradesPlumbers_alabama-plumbers()
but it did not work.

It would be best for SEO to have the URL read /residential-commercial-plumbers/alabama-plumbers

Is it possible to use history.pushState in the view function?

Sorry for my hesitations, I don't want to cause a major js conflict that will cost me hours of work just to undo.

Thanks!

*additional thought*
or would it be better to create a selection array in the function to display city and state similar to the way the event calendar does month and year?

view_pcTradesPlumbers_usa()
$location


/residential-commercial-plumbers/usa/birmingham-alabama


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

updated by @the-patria-company: 10/17/18 11:40:14AM
michael
@michael
6 years ago
7,714 posts
I don't believe - _ is relevant in 2018.

Hyphens can not be uses as function names. If you must have them, then you could use the default() function and handle it with a switch.

view_pcTradesPlumbers_default($_post, $_user, $_conf){

switch($_post['option']){
  case'alabama-plumbers':
  // put all your logic in here   

break;
}

}
PatriaCo
PatriaCo
@the-patria-company
6 years ago
349 posts
THAT WAS ABSOLUTELY PERFECT!!! Exactly what we needed. Thank you so much!!!


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

Tags