Search the Community
Showing results for tags 'URL segment'.
-
Hello! I want to keep sort some pages in my page tree within a single parent, but then have the URLs for those pages ignore their topmost parent. So for example, if the page is at: [home]/buildings/architect-name/building-name I want the URL to be /architect-name/building-name I've search around the forum, and the solution that comes up everywhere is a version of the code from this post: /** * This hook modifies the default behavior of the Page::path function (and thereby Page::url) * * The primary purpose is to redefine blog posts to be accessed at a URL off the root level * rather than under /posts/ (where they actually live). * */ wire()->addHookBefore('Page::path', function($event) { $page = $event->object; if($page->template == 'post') { // ensure that pages with template 'post' live off the root rather than '/posts/' $event->replace = true; $event->return = "/$page->name/"; } }); And I can use a version of that to successfully get buildings/architect-name to appear as /architect-name But /buildings/architect-name/building-name still appears as /buildings/architect-name/building-name Is there a way to get URLs to ignore/remove that topmost parent even when the page has a grandchild? Any help much appreciated!
-
Sending ajax data from multiple page to one template
louisstephens posted a topic in API & Templates
So I have a project where multiple pages are sending POST data to 1 single template page. All was working well (well, at least with one ajax post), but now I have hit a stumbling block. I figured the "best" way to handle the request were to use url segments and then use the following in the status page: if ($config->ajax && $input->urlSegment1 == 'add-bookmark') { // some code here } However, this doesnt seem to really work (as I assume the the request isnt being posted to /status/ but rather to /status/add-bookmark/). What is the best way to actually handle this?- 2 replies
-
- ajax
- url segment
-
(and 2 more)
Tagged with:
-
Hello All, So I've launched my first PW site: http://www.neighborhoodsewerdrain.com - yea! Next challenge: We have an 11 county service area in south east Michigan. My boss would like the site to function in such a way as to "localize" the site depending on where the user is located. So, if the user clicked on a Google AdWords ad targeted at Macomb County, the URL would be "www.neighborhoodsewerdrain.com/macomb/". From there, I'd like to pull in dynamic content specific to that region, like a local phone number, the words "Macomb County" wherever I want to drop them in the content (most likely using Hanna Code or code in the template). Further, once the user enters through the above sample URL, I'd like to prepend "/macomb/" to the root domain as the user visits other pages, which will keep the content localized. This would be ideal so as not to have to manage 11 different versions of each page. I've begun to experiment with URL Segments and PHP switch statements. I'm sure it's going to get a bit more complicated than that. So, if anyone can point me in the right direction with suggestions on how to pull this off, it would be most appreciated Thanks!
- 2 replies
-
- multisite
- virtual path
-
(and 1 more)
Tagged with: