-
Posts
6,798 -
Joined
-
Last visited
-
Days Won
158
Everything posted by Soma
-
Sorry to disrupt you discussion. Why not simply use https://github.com/somatonic/MarkupSimpleNavigation ?
-
Module HelperFieldLinks - field and template edit shortcuts
Soma replied to Soma's topic in Modules/Plugins
I just commited a fix to this module causing some issues with a not well formed span tag. I noticed when I got problems with it adding other markup using hooks to inputfields. I've seen some people using this module so I thought I'd make a note . -
I quickly looked into it and created an additional hook for what you might after. There's my other already created ones you can also test and comment it if not needed. It's a snippet I just posted here https://gist.github.com/2878361 Uncomment unwanted hooks int he init() method of the module. The third hook... $this->addHookAfter("InputfieldPageListSelect::render", $this, "findRelated"); does look for any pages that has the current edited page selected in a page select field. You can specify what field you want to attach it in the function findRelated(): $field_filter = "select_architect"; Let me know if it works for you.
- 8 replies
-
- 1
-
- reciprocal
- pages
-
(and 1 more)
Tagged with:
-
This is possible with a simple module that hooks us in after the page "save", then retrieve the page object so you can check for it's template. You can find an example module in your site/modules/HelloWorld.module and look at the hooks and the example2() function. There you also see other examples of hooks. If you're into PW's API it's quite simple as it's the same as if you would code template code, just a different context and maybe more advanced. I don't think there's also a "onfirst" save event that could be hooked. So what you want to have, is a check for if the two pages are already created under the page and omit the creation of the two children pages.
-
Actually I'm recently working on a module that lists links to selected pages on a page field when on edit page after saving. Doing something else would be quite easy with one of the above methods. I'll have to pick it up see what I can share.
- 8 replies
-
- reciprocal
- pages
-
(and 1 more)
Tagged with:
-
Just rewrote my previous post multiple times... lol. Got little confused.
- 8 replies
-
- 1
-
- reciprocal
- pages
-
(and 1 more)
Tagged with:
-
Just went through this old thread and noticed that there's no link or note here that there is a module for this already. I created the PageEditSoftLock module for this particular problem, with a little help of Ryan to get easy starting. I got it installed in all our PW projects and it won't lock the page completely (still editable) but throw a fat red message and a js alert. It workes very well and has been a saver already a couple times preventing two people editing the same page. It has been released here: http://processwire.c...edit-soft-lock/
-
Not sure if I understand right. Edit: If page field is limited to one page max you could also do this if($page->related->related === $page){ // related page has this page also referenced } else { // it's not } Edit2: corrected a previous example if multiple page field with better example if(count($page->related)){ foreach($page->related as $rel){ // check recursively if one of the related pages has this page in it's related pages if($rel->related->has($page)){ echo "<li>$rel->title</li>";// related page has this page also referenced } else { // it's not } } }
- 8 replies
-
- 2
-
- reciprocal
- pages
-
(and 1 more)
Tagged with:
-
This "bug" has already been reported by me in the repeater thread, though nobody seems to recognized or understand it. Thx for bringing this up
-
Thanks! Tested and it works. Pagination also works. Yeah that makes sense looking at how you did it.
-
Have you tried in deeper levels too? I can't get it to work with anything deeper than 1st level. like /en/template/page1/[s1]/[s2] I can't solve it right now, too tired. Edit: I think found that the "$parent = $page" for temporary saving if page is not found is causing the issue. My bad, was my fault coding it this way.
-
mcmorry, the code I started for urlSegments remapping is completely wrong logik. Hope you get it. I figured that you simply need to add a counter everytime a page is found, to then, after the foreach, unset them by this count. Also I found that with this method you'd better remove urlSegments if the page requested was resolved without any segments. Or it will still have urlSegments from the language root page... Let me know if I can help in anyway.
-
Made a little update to this module. I strongly encourage to update with the latest version. - unfortunately it stoped working in the latest PW since script/css version (..script.js?v=100) in the admin were introduced (1,5 months?). Since I have to manually str_replace the script tag into the header right after jquery core js, it failed because the string is now different :/. Changed it to use replace on another location/part of the code which will hopefully stay there. - added the admin root path to the script url, so it now also works on PW installed in a subdir. - added script versioning appended to file name ..?v=101.
-
Thanks Ryan. Yes reindex. I implemented a unset function in the WireInput to test this, and I get unexpected behavior if the page is a subpage which both use urlSegments. Not sure whats causing it , or if its the default behavior or not, I need to make some more tests. Maybe it's my code in the module causing it. basic-page (urlSegments enabled) Parent (basic-page) Child (basic-page) if on Child it will include it in segments. /parent/child/segment1/ it will be segment1 = child segment2 = segment1
-
I just tried to extend the WireInput, but no luck, as I don't understand it completely. Yeah it could also be a method added to page. PS: Yes you can in the config.php. $config->maxUrlSegments = 4
-
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();
-
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.
-
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.
-
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.
-
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.
-
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; }
-
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" : ''; ...
-
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
-
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 "?".
-
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"