-
Posts
6,798 -
Joined
-
Last visited
-
Days Won
158
Everything posted by Soma
-
You could login yourself with API and try.
-
It's not really tested in IE's but it looks pretty solid so far.
-
Now Im still confused even more. You say it should always have the same value but still different for each language. My last suggestion works with what?
-
This has nothing to do with languages anyway.. Your code is missing the ..->url at the end.
-
Then why do you make it a language field at all? Btw why not just add the field to home and alway get it from there? $pages->get("/")->company
-
I'm not sure I understand completely. How is the headline (field?) the company name? This is usuall the alternative title on a page. The languages are set/taken automaticly depending what url you you access the user langauge will be set and if entered it will take that language if it is a language field. If language value is empty it will get default language.
-
Yeah a couple days ago. Glad you got it working.
-
You mean the label offset? Yeah there's no easy fix I kinda gave up not finding a solution after a while. But in dev branch it's replaced with a ui button.
-
I just recently did create a code example to generate a language switch with LanguageLocalizedURL that might be of interest. https://gist.github.com/somatonic/5130992 And linked from in the readme of the module https://github.com/mcmorry/PW-language-localized-URL/blob/master/README.md#language-switch-example
-
How to keep pages organized when managing lots of landing pages
Soma replied to evanmcd's topic in General Support
Ok sorted it out. You can't use multiple or | with name field in a selector, since name it's not a text field like others. So to make it easy you would have to first check if there's one with "name" found or check for further fields. Here's a working code with some notes you would have in your home.php at the top. if(count($input->urlSegments) > 1) { // not more than two segments throw new Wire404Exception(); } if(count($input->urlSegments) == 1) { // sanitize to make sure it's valid page name $seg1 = $sanitizer->pageName($input->urlSegment1); // search for name since name can't be used with or "|" multiple field selector $found = $pages->get("parent=/landing-pages/, name=$seg1"); if($found->id) $session->redirect($found->url); // if page with name of url segment not found search alternative fields.. $found = $pages->find("parent=/landing-pages/, short_url=$seg1")->first(); if($found->id) $session->redirect($found->url); // if we reached here, nothing found, throw a 404 throw new Wire404Exception(); } In case you want to leave at the short url and not redirect, you could just render the found page and exit: if($found->id){ echo $found->render(); exit(0); } In case you got questions just ask. -
How to keep pages organized when managing lots of landing pages
Soma replied to evanmcd's topic in General Support
Theres some changes that can be done. Ill come back later when im at home. What is vanity url and generic text? -
$page->done isnt needed. :-P
-
Thanks diogo, yeah might some in there that is not needed. It was original from a repeater on page and done months ago so might not all right there for simple page, just edited it in browser quickly. Edited my example. Does it work like this?
- 11 replies
-
- data structure
- fields
-
(and 1 more)
Tagged with:
-
To populate a field on save you can create a autoload module (see HelloWorld.module) And do something like this $this->addHookBefore('Pages::save', $this, 'addTitle'); public function addTitle($event) { $page = $event->arguments[0]; if($page->template->name !== "product") return; $page->title = $page->somefield . " " . $page->field2; }
- 11 replies
-
- 1
-
- data structure
- fields
-
(and 1 more)
Tagged with:
-
You better not merge but replace the new "wire" folder. Since session module is now in it's own folder (with db session module) this happens if you merge it with old wire folder. So there's 2 instances of the same module.
-
If the garbage collector on server is set wrong this can happen. The good news, there's is now DB session module in PW since some versions in dev already to handle session via DB. Just install it. https://github.com/ryancramerdesign/ProcessWire/tree/dev/wire/modules/Session
-
I'm not sure this was already before but when editing page there a token doublicate in html source: <label class='ui-widget-header' for=''>Children / Subpages</label> <div class='ui-widget-content'> <div id='PageListContainer' data-token-name='TOKEN1566834131' data-token-value='e633e7ae0a8d5d91d6a630f0d180853b655a560ade29f71a8f9c1e279bc2c09d'></div> <div id='PageListContainer' data-token-name='TOKEN1566834131' data-token-value='e633e7ae0a8d5d91d6a630f0d180853b655a560ade29f71a8f9c1e279bc2c09d'></div> <ul class='Inputfields'> ...
-
Thanks Ryan, this sounds great news!
-
How to keep pages organized when managing lots of landing pages
Soma replied to evanmcd's topic in General Support
Or url segments on the root template. -
The above example already has lots of overhead so the more optimized way would be to avoid as much get or find and template stuff and do something like this: function segmentUrl(HookEvent $event){ $url = $event->return; // requested url $segment = "/about/"; if(strpos($url,$segment) == 0){ $event->return = str_replace(rtrim($segment,'/'),'',$url); } } $wire->addHookAfter('page::path', null, 'segmentUrl'); Will be a lot faster.
-
As example to "rewrite" the url of certain pages, this is possible within the template code: function segmentUrl(HookEvent $event){ $url = $event->return; // requested url $pages = wire("pages"); $page = $pages->get($url); $segment = $pages->get(1001); // get segment we want to strip // for example only for certain pages under a certain section if($page->template == "basic-page" && $page->parents->has($segment)){ // set event return the stripped new url; /about/childpage/ becomes /childpage/ $event->return = str_replace(rtrim($segment->url,"/"),'',$url); } } $wire->addHookAfter('page::path', null, 'segmentUrl'); Or similar as in a autoload module (HelloWorld.module) it would be almost same code, just $this->addHookAfter("page::path", $this, 'segmentUrl');
-
Do you really think "domain.com/drills" is a good strategy? Have all pages on the root? You miss a lot of if you reduce it that way. There's no way to surely determine a single page name, because there can be multiple of it, and you can't control it anymore. I'd consider this for shortcut urls you use in print or something, but not as a general approach to the site on all ends. At least have a category domain.com/powertools/drills/ that gives you powertools as a category. There's maybe too many ways and scenarios with build a urlSegment system, and I would advise to use it only where really needed. How you approach it also depends also a lot how you structure your page tree with what templates. To construct some category/product urls segments are great. Where category is itself a page you use with a page field to categorize product. Then the category pages with url segments enabled and list products that belong to that category, or if url segment present show a detail page. That's how I use url segments to virtualize a structure that is different from the admin. But leaving the real url intact would sure make sense to use canonical urls or redirects to solve it. You can alter the url path PW generates, so a hook into page::path or page::url would do the trick to strip out segments. Once you have that url hook in place it would also effect the Wysiwyg urls generated. But this comes maybe with some overhead added to what might get called thousands of times, though not noticeable unless you go wild. You can also have the template file for those pages redirect to a shorter url and use that template only to construct it.
-
you have "page-edit" permission in module info. So my editor can see it. Is this intentional? Could you change it to "batcher" or something to give it to users instead?
-
Sure you have to do some extra efforts but it's not that hard as it might first seems coming from others systems. No problem. But this way you are in full control and can change it the way you like and are not restricted to some built in feature.
-
Maybe also look at this example here https://gist.github.com/somatonic/3558974