-
Posts
6,800 -
Joined
-
Last visited
-
Days Won
159
Everything posted by Soma
-
How to add children to an instance of Page using the API?
Soma replied to bytesource's topic in API & Templates
You can't have "children" or "parents" in a Page or WireArray. It's a one dimensional thing. You could create your own 2 dimensional array storing the id's and then iterate that to create the navigation. You could create the navigation directly from the categories and list pages that belong to the current category. I'm not sure about your menu example, as I don't see where the products are and such, it's just the categories as is. So without really see all context and needs according to your code I would do it like this. $navcode = '<ul>'; foreach($categories as $category) { $navcode .= "<li>$category->title"; if($children = $pages->find("template=offer,product_category=$category")){ $navcode .= "<ul>"; foreach($children as $offer) { $class ($offer === $page) ? " class='active'" : ''; $navcode .= "<li$class><a href='$offer->url'>$offer->title</a></li>"; } $navcode .= "</ul>"; } $navcode .= "</li>"; } $navcode .= "</ul>"; $nav->set('navcode', $navcode); -
Is there an idiomatic way to handle global variables using the API?
Soma replied to bytesource's topic in API & Templates
I don't see any abuse here. $config is a good way to do it, it's there for such things. -
I see what you mean. I use my teflon theme so I don't know this problem as the top menu are dropdowns and it requires me 1 click to get back anyway. You could use my theme or place the "Modules Manager" admin page on root, instead of setup. Well, it's possible of course. It would require a hook for the ProcessModule to render a link back to the Modules Manager. Since Modules Manager isn't autoload but a process module only loaded for that particular admin page, it's not something that can be done within Modules Manager and would require an additional module just for that. Modules Manager is planned to be integrated in core at some point, so there will be lots of changes and improvements needed and will replace the current module page.
-
Thanks for the likes It means a lot to me you guys seem to really like me. I don't know what this number means but it's a little scary... heh
- 16 replies
-
- 23
-
-
Just for convenience: http://processwire.com/api/cheatsheet/?filter=hidden&advanced
-
The magic selector include=hidden does the trick.
-
Theyre not messed up at all more a slick playing ground which also helps spotting possible issues with other modules an upgrade paths. What you could do is let the installer there and just clean db and files and run installer again. Or use shell script to quickly rsync and copy a clean install over your existing. If you want to start new module or theme you can also spend 1 minute to create clean install.
-
I have a shell script to do a copy of an install to copy files and db. I only use this to dev live copy the current state. For developement and testing i only use 1 or 2 installs i have since a year. No need to install a new pw just for creating a new module or theme. So dont understand your need to do so.
-
The forum is full of example for it if you search for it enough Basic code needed to add new pages would be. $np = new Page(); // create new page object $np->template = "basic-page"; $np->parent = "/about/"; // or id or page object $np->title = "Hello World"; $np->save(); It's very easy once you get the hang of it. There's a lot more you can do and sometimes it can be handy to know it to import stuff and create pages via API or in modules. If you want to can take a look at my super duper page creation tool, which is a work in progress but you can add endless amount of pages while looking TV. http://processwire.com/talk/topic/2138-process-tools-create-pages-wip/
-
Trying to get the first object with a condition
Soma replied to tinacious's topic in General Support
Edited post for you Nik.- 16 replies
-
- 1
-
-
- conditional
- foreach
-
(and 1 more)
Tagged with:
-
Ah you mean it shows the php code on the Website? This is php code and you have to put it in <?php ... ?> to make it work. Sorry but this is so obvious that I didn't think of it.
-
Trying to get the first object with a condition
Soma replied to tinacious's topic in General Support
Guys coordinate your responses, hold straight.- 16 replies
-
- conditional
- foreach
-
(and 1 more)
Tagged with:
-
It happened to me. I wrote some post and after posting it was gone forever
-
Will checkout. Link is broken!
-
I still don't get what the problem is. "language" template you don't need to do anything anyway, that's why it's a system template. Getting language is simply $user->language->name. And you'd have to do this once in your templates code if you do it "right". Actually Ryan is a designer and coder, and compared to most out there, that call themselfs designers, he's even better. ;-) I don't think there's much UI issues, well not more than with any other CMS software. Localized urls? You mean using the LanguageLocalizedURL module? Even there you don't really need a extra field. Yeah it's obvious.
-
Autocomplete and Other Search Enhancements
Soma replied to Michael Murphy's topic in Getting Started
According to autocomplete documentation you'd have to do something like this (works). $('#search_query').autocomplete({ source: function(request, response){ $.ajax({ url: '/search/', type: 'get', dataType: 'json', data: { 'q': request.term }, success: function(result){ response(result); } }); }, minLength: 2 }); -
Autocomplete and Other Search Enhancements
Soma replied to Michael Murphy's topic in Getting Started
Have you tried 'data' instead of Data. sorry mobile autocorrect.. -
Autocomplete and Other Search Enhancements
Soma replied to Michael Murphy's topic in Getting Started
Try Data: { 'q' : q} -
No it's nice to have and ... Hmm but it doesnt work at all?! Even with only german as the default. Damn, all this software is so english orientated. But in this case I think ... Not sure. If we take it out it wont be available in english aswell. Well I tend to think for date inputs it's not that important as long as the output works. But for sure annoying it can't be used.
-
Autocomplete and Other Search Enhancements
Soma replied to Michael Murphy's topic in Getting Started
Maybe trailing slash? Ryan. I think source is for the params. -
Little afterwards question to this subject. When changing a language title field (only changing one of languages) getting $page->getChanges() it gives 0 => title 1 => title Would it be possible to also see what language field has changed of title? Minor but thought it would be great to have the possibility.
-
Works like a charm now! Thanks Ryan!
-
Yep the Datepicker does the translation, and it seems converting it back does fail. In master version 2.2.9 there's no translation happening from the Datepicker, so you're right. Certain formats like "Y-M-j, l" work but get translated back to english when saved which is wierd. I guess the best would be to have the input digit based as you say. I can live with that. Thanks
-
It doesn't matter, anything that has strings in it for months and days. For example "j F Y" or "l, j F Y" get's cleared when saving. Following does to work on the other hand "Y-M-j, l"