Jump to content

Soma

Moderators
  • Posts

    6,808
  • Joined

  • Last visited

  • Days Won

    159

Everything posted by Soma

  1. It's not possible I think. WireInput isn't extending Wire /WireData, not sure if that's correct, but I think. Not sure what you mean with "I can't search for a function with "___" prefix?" I don't know if adding a new property to the wireinput will be good. I'm eager to hear Ryans opinion on this also. As I'm not sure what would be best. However you could also add a method to the module that can be used to have mlUrlSegments array in template public function mlUrlSegments(){ $urlSegments = null; if($this->page->template->urlSegments) $urlSegments = array_slice($this->input->urlSegments,count($this->page->parents)); return $urlSegments; } in the template call it like this. $urlSegments = $modules->get("LanguageLocalizedURL")->mlUrlSegments();
  2. As I wrote before, it doens't work without hacking the WireInput class, it doesn't have any hookable functions. And urlSegments array is protected. To get it to work, uncomment my code and add this method to the Input.php WireInput around 226 after setUrlSegment($num, $value) /** * Unset a URL segment value * * @param int $num Number of this URL segment (1 based) * */ public function unsetUrlSegment($num) { unset($this->urlSegments[$num]); } In PW all hook-able functions have "___" prefix.
  3. Ah, sorry didn't recognize you made a dev branch. You could have waited for me to change it or not just pull in to master but commit it manually to your dev branch. Sorry for the inconvenience. urlsegments remapping My idea was to do it in the module and I did it, but uncommented the code because it requires to add a method to the core WireInput class to allow to unset the urlSegments array, which is protected and can't be done without (or I don't know how). Maybe if Ryan is willing to implement a unsetUrlSegment($key) function this could work out. I'm not sure what this would mean to the system, and I haven't done much testing. So yes if it would come to be, there would have to be a option to disable or enable it. By default off, I don't know. side-effects or drawbacks It's not as worse as I orignally thought before this subject and module came to be. But there's still some things to consider. Mainly just thinking about what could stop working or is not possible (for now) taking this approach having multiple languages on one page. For example access management, you can't manage language separate and give separate access to them. The publishing has to be done with a workaround and will then have to take care of both in all template and possibly module code. Third-party modules, for example AdminBar doens't work together with this module. Mostly front-end modules I think are affected depending how it's done. Having PW's ->url replaced does really solve a issue that would be worse when having to use ->mUrl(). The system outputs default language if alternative isn't populated. This behavior is, as I understand, because it's build for the admin. I don't wan't english text to be shown if a german text is left out. I haven't really looked into it, and how it should be treated. The approach in generating the slug from the title of the language, could cause troubles. Changing the title is too easy, which will result in different url. Alternative language field aren't required. Having "id_" will solve the issue of doubles under 1 tree. Though I'm not happy using it because it add an element which can stop some modules from working that use the url or path. So having then instead the $page->mUrl method back and use it only for navigation of the site, will still cause troubles in any module using the url or path. Mainly I worried about replacing the url method of PW. It works better than I thought, when excluded from the admin template. But what will this mean for other development of modules. MadeMyDay uses this module, together with the Multisite module, which also does hook the path method. He seems to have solved it without much troubles. That also speaks for PW being a flexible and well thoughtout system Ryan has put together here, so most of the issues can be solved in one way or another. And Ryan is open to new stuff and will certainly help us and implement necessary functions or features. Edit: Another thing I noticed that if a parent page of the current page is unpublished the page isn't available too. This behavior is due to the way it parses the urlsegemnts.
  4. Thanks mcmorry for the pull. I don't see this as an issue. It depends on how you make your urls on the site. If you consistently use one of the url approach, search engines will never know there is a url without the "1002_". This has been mentioned on the last posts. It is now like this and you can use $page->url normally. I don't see any problems here. URL segements are now supported and still can be used if you enable urlSegments on the template. I implemented something that won't throw an 404 if a segments isn't resolved to a page and urlsegments are enabled. Of course it also contains the segments from the language root pages (/en/, /de/). But you can easily slice them of using the $page->parents count. So you end up with an array containing only the segments from the current page. As example, put something like this in the head.inc. $urlSegments = null; if($page->template->urlSegments) $urlSegments = array_slice($input->urlSegments,count($page->parents)); And later you can use the urlSegment array in your template code: if($urlSegments){ echo "<br/>urlSegments: "; print_r($urlSegments); } Or just use the $input->urlSegment as ususal, just have to be aware what level you are using it. You could also simply use $input->urlSegment(1 + count($page->parents)); And it also works now with using pageNum for pagination if enabled on template of the current page. No need to change anything. There's some things to account for if using this module, and it has various side-effects , but so far most of it can be worked around with the excellent and system and simple API. I think for simple multilang sites, it will work quite well. I wouldn't recommend doing a big and complex site using this approach yet.
  5. Another update I worked on I commited just now. The theme has now a modules navigation dropdown. It shows all modules by section. Uninstalled modules have only a anchor link to the modules page, it will scroll to the module. If you're already on modules page it will also scroll to the module. All installed modules will get you to the edit screen of the module. Configurable modules are marked with the gear icon. Enjoy.
  6. Thanks for creating it. I was just about to create on e today. Ok I'll look at it again later but to get it work in admin you need to exclude admin template and it works like a charm. Here's my mlUrl. Note the $page->template == 'admin' .. I also fixed the homepage url in here. public function mlUrl(HookEvent $event) { $page = $event->object; if($page->template == 'admin') return; $includePageId = false; $includeParentId = false; if (count($event->arguments) >= 0) { $includePageId = $event->arguments(0); } if (count($event->arguments) >= 1) { $includeParentId = $event->arguments(1); } // add the language code at the beginning of the url $lang = $this->user->language->name; if (!$lang || $lang=='default') $lang = $this->getDefaultLanguage(); // if on homepage return current language root if($page->id === 1) return $event->return = "/$lang/"; // generate the url using titles and, evetually id $path = ''; $parents = $page->parents(); foreach($parents as $parent) { if($parent->id > 1) { $path .= "/".($includeParentId?$parent->id.'_':'').$this->toSlug($parent->title); } } $url = $path . '/'.($includePageId?$page->id.'_':'').$this->toSlug($page->title) . '/'; $event->return = '/'.$lang.$url; }
  7. Nothing wrong with the code, but it looks to me as the /team/ page isn't rendered in this code. What it does is output the children of /team/ not news itself. Have you anther code that's rendering the /team/ page? Edit: Ah I think you mean, the current page isn't active. Misunderstood that. The get current page active you have to change it to this: $class = $child === $page ? " current-menu-item" : ''; ...
  8. Just wanted to mention that I added $input->urlSegments to the sheet. Along with some code cleanup. I also added the possibility to link and tigger the filter/search on the sheet. Examples: http://processwire.c...ter=urlsegments You can set the advanced mode with &advanced. http://processwire.c...gments It also supports hashes processwire.com/api/cheatsheet/#input
  9. That's a IHNI error. (I Have No Idea) Just guessing. You'r doing some ajax on the page? Comments saving for guests, Poll, ... ? I always wondered where the questionmark comes from "?".
  10. Thanks guys! Glad it is getting used by some.. Just forgot to mention that the theme also now supports the config for a site name that will show in the admin html title. That is helpful if you make bookmarks or in other cases. If you don't specify the config value it will output domain by default. Config example. Put this code in the /site/config.php at the bottom: $config->siteName = "Local Dev PW2.1"; "Pages • Local Dev PW2.1 • ProcessWire"
  11. Yah! First poll! For fun, but also seriously...
  12. Yeah, maybe it's not as ideal as one may wish it to be to enter translations. But it's pretty decent start. As I understand it, it's using gettext and it uses textdomain for each file/module in the context of it. This may seem inefficent, but one global file for all words used all over the system would be a nightmare. One phrase used in the context of a module may be differently translated in the context of another module in another language. Note also context information (descr) can be added right after the translation syntax, that will show in the translation editor. I think it's well thought out by Ryan, even though there's always things to improve. Maybe he also pops in to give his statement.
  13. Ah. Then are you using the translation for frontend template? I tried it once and got away from it for various reasons. I still use translation files for frontend translation (for the static terms, forms etc) using yaml file for each langauge. So it's much easier to compare and have them in a readable key -> value format. It allows me to define them like: label_send: Send ... Then in templates I can use it like: $txt['label_send']; In the head I include and determine the langauge using this code: require_once($config->paths->root . "site/libs/yaml/sfYaml.php"); require_once($config->paths->root . "site/libs/yaml/sfYamlParser.php"); $yaml = new sfYamlParser(); // parse language file $txt = $yaml->parse(file_get_contents($config->paths->root . "site/languages/" . $lang . ".yaml")); I use this php yaml parser lib https://github.com/fabpot/yaml
  14. Why? I've never had the feeling I need to edit them directly in the file. Edit: Maybe something like this does help? http://www.jsoneditoronline.org/
  15. Yeah I mean it serious!! Hehe thanks a bunch Ryan, it actually works! Funny solution I'd neve thought of myself. How comes it is like this? Is there something like outputformatting to turn beautifier off while creating pages?
  16. For same reason Ryan mentions. I believe there's this need, as the web is a child of print, but those rules/habbits that were true to the print medium doesn't apply well in the new dynamic medium. The industry, and people in general need to first grow on it, and is only yet adapting which will take some more years or even decades. I don't say there's no solution for this problem in particular mentioned here and maybe wasn't really a problem as of now (devices are not only desktops anymore), so it's coming back at us for not yet considering/knowing.
  17. Ok thanks for mention. Then I guess it's because it's theme dependend. Couldn't this be done without, and add hidden to such things (as with the mastheader) inline? Every such feature will require to update all themes in the future and can be a trap or/and annoying. Maybe it doesn't make sense, and can't be done as I think. Just wanted to mention it. Sorry, now trying to find the issue, it was a "fault" on my side. The process input css is the one hiding it with absolute position and I overwrote without knowing the context class to add padding and top attributes, thus overwritiing the top -9999 of the core css. So it's all good I guess anyway
  18. Ryan, he means the default URL description text. Which is nice, but if you enter a space in the description there will be still a space above the input text field. I figured that adding in a 0 (zero) will ommit it completely, thus no space anymore. I think there should be the default text in the field description, or none at all. So you can input or leave it empty, without asking anyone. AS for the other problem of field heights. It's annoying and I started a js script that would set all (in one row) to the height of the highest. Unfortunately it's more of a bad hack to something that should be possible in browsers since a decade (imho) and will fail for the reason you mention. Maybe we will find some solution here that works better.
  19. I have an import script that imports static html pages via API script. Some of the pages have a name like "001._pagename.htm". Untill now it worked and the name of the page was the same and links worked to those documents. Yesterday I did an update to latest PW, now it changes the name to "001-pagename.htm", and links stop working cause the name is different. When and what did change? I think the previous core version was 2.1 or something. Can this be changed or avoided? $p = new Page(); $p->parent = $parent; $p->template = wire("templates")->get("gb-page"); $p->name = $filename; // sanitizes string different now $p->title = $title; $p->body = $dom; $p->addStatus(Page::statusUnpublished); $p->save();
  20. apeisa, yes that's what I did. I thought why so complicated if there's a nice method to add those in PW. Sorry to not explain further.
  21. I don't understand why and what exactly you did. But for having $page->children()->renderListItem(), you could just simply create a module to add that method to page array objects. I've done similar things in a project.
  22. Hey Jeff, thanks for the nice words. I agree with you here. ProcessWire aim is to keep things simple and I enjoyed contributing to it with this nice little resource. Hope you enjoy your stay
  23. Minor, but when I edit a field on the template setup, it opens in a modal window and the header of the admin template is hidden. There's this context select on the top right. When I select something it reloads the page and the admin header is suddenly shown. Seems it doesn't recognize being reloaded in the modal context.
  24. Well, then I have something for your scientific spirit! function turnPage(){ turnPage(); } turnPage();
×
×
  • Create New...