-
Posts
212 -
Joined
-
Last visited
Everything posted by Roope
-
How about if you wan't to add logic before saving new page? I'd like to prefill page title and name fields when new product page is added. I've tried hook it to ProcessPageAdd::execute but don't know how to set field values here before form is rendered. If I hook before Inputfield::render I'm able to pre-set values for both title and _pw_page_name but this doesn't look right... public function createItem(HookEvent $event) { // limit action to admin pages only if (wire('page')->template->flags & Template::flagSystem) { // get parent page $parent = isset($_GET['parent_id']) ? wire('pages')->get($_GET['parent_id']) : null; // add this to item pages only if ($parent && $parent->template == 'items') { // get the current field $field = $event->object; // proceed on (empty) title and page name fields only if (($field->name == 'title' || $field->name == '_pw_page_name') && $field->value == '' ) { // finally, set the value $field->set('value', 'some_val'); } } } }
- 23 replies
-
- page
- after saving
-
(and 1 more)
Tagged with:
-
Thanks guys! There's no stupid questions, only stupid people. Being such a OOP noob this object behaviour was completely new to me. Wonder why I haven't faced this earlier though. Could it be worth to add a mention about this to the default template head.inc? // In this case we also want the homepage to be part of our top navigation, // so we prepend it to the pages we cycle through: $homepage = $pages->get("/"); $children = $homepage->children; $children->prepend($homepage); Because it says in this case, some another freshman could think that second line is there to keep $homepage->children intact.
-
Hi all! This odd behaviour came up on one live site I build just little while ago. I have two Page fields at home page: advertize_homepage advertize_sidebar At homepage template I get all pages from both and echo images to slider: $slides = $page->advertize_homepage; $slides->append($page->advertize_sidebar); $slides->shuffle(); foreach ($slides as $slide) { ... } I noticed that later when I get $page->advertize_homepage and loop results, it holds also pages that are set to $page->advertize_sidebar. Array is also shuffled. Here's reduced testcase: <pre><?php echo 'items before: ' . count($page->advertize_homepage) . "\n"; $slides = $page->advertize_homepage; $slides->append($page->advertize_sidebar); $slides->shuffle(); echo 'items after: ' . count($page->advertize_homepage); ?></pre> Result: items before: 8 items after: 15 I'm using latest dev, tested on PHP 5.3.23 and 5.4.10
-
Clarification to role permission: Administer users
Roope replied to Roope's topic in General Support
OK, thanks for clarification. Sure I didn't try to save superuser role but was just suprised to see it there as option. -
I'm not sure if I understand PW's user and role logic right so let's go trough simple scenario: Site has two custom roles: 'admin' for site administrators and 'member' for closed member area login. At roles 'admin' has every permission enabled and 'member' has none (view pages only). Admins need to have permission to create new members. OK, so first I need to go and edit 'user' template and give 'admin' role full edit rights. Then I log in as 'admin' user and browse to Access > Users where I can see all user accounts except superusers. When I edit any existing account or create new one, I'm able to select 'superuser' as account role. I think this is not right? It would sound more logical that user who has permission to administer users, would only be able to do this for accounts that have the same role(s) enabled. Eg. at Users main page it would only list users belonging to same role(s) and when creating new account or editing existing one there would only be same roles available to choose from.
-
OK, fair enough. If I find some more info about this issue I'll post it here but for now I just have put pressure on ISP to update their MySQL.
-
Sorry about that jQuery.. edited and deleted. That profile exporter issue was just a side note that I noticed when I was trying to solve the main issue: Some images do not end up to database during upload and that's why they dissapear from input field after page save. All images do trasfer to filesystem correctly. So I belive it's a MySQL issue since only setup where I can reproduce this is at PHP 5.3.23 / MySQL 5.0.8 (although tested only couple of different combinations available). I can PM you some login details to live site if you wan't to go explore. That jQuery break notification on firebug probably has nothing to do with this.
-
OK, so I re-tested this issue on PHP 5.3.23 and mysql 5.0.8 server using both; dev and master branches. On fresh install issue exists with both of them. There is actually Break Notification on page load when image field is attached to it: JSON.parse: unexpected character. But it so it does on local machine also where image upload works as expected.
-
Thanks for the reply guys! There's only couple of site modules installed that I don't think is doing any harm here (Import Pages from CSV, Email Obfuscation (EMO), Export Site Profile, Video embed for YouTube/Vimeo). I haven't noticed any JS errors or anything. That MySQL error I posted before is the only one. I just intalled site on localhost running PHP 5.4.10 and MySQL 5.5.29 and all images are saved correctly so I think this may have something to do with old MySQL version that hosting company has installed (5.0.8). I do have couple of other sites on that same server though and haven't noticed any problems before. There is no option to choose another version so I can't test it at the moment on live server. I also didn't succeed to install this site from SQL-dump created by Export Site Profile. There was some errors during installation: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'name1010' in 'field list' and when I try to enter admin or view any page it just throws: Error: Call to a member function isDefault() on a non-object (line 490 of /Users/Roope/Sites/demo/wire/modules/LanguageSupport/LanguageSupportPageNames.module) Wire folder was fresh copy from dev branch (last update today 02.09.2013)
-
Hi! I have this annoying problem on one of my clients site using latest dev. When images are uploaded, all of them show up to image field and files are transferred correctly to page folder. After page save some random images disappear from field. Couple of times I received error during upload (page id 1090): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1090-0' for key 1 Though usually there's nothing and no errors show up to log file. I've tried to add files one by one or by dragging several at the time and no difference. Some images get lost in the way. It can be one from two uploaded files or one from eight. File that gets skipped can be uploaded fine next time. PHP version is 5.3.23 and mysql 5.0.8-dev. Memory limit 256M. Any help would be much appreciated!
-
Thanks for the fix!
-
OK, so I was able to reproduce this scenario: when you use PageTitleLanguage fieldtype with only default language installed, content of the Title field is not editable. Content does not change after page save. Problem is solved when you install more languages to PW. Maybe this thread should be moved to Multi-Language Support forum instead where we can discuss is this even bug since why would you need PageTitleLanguage field with only default language installed. Well, I did so because we will have different languages for the site in the future but first release will be only in finnish.
-
I have very strange problem on one little multilingual site that has only default language set at the moment. I can only edit Title field of Home page but all others are uneditable. The text that was used on creation rolls back after page save. Title is editable via API though. Site is build on dev branch. Just pulled latest updates but no change. There is only admin hotkeys and emo modules installed (except language support). Default language changed to finnish and here is only error that system throws on page save: Session: Missing required value (_pw_page_name) Could this be some bug on PageTitleLanguage module or is there something obvious I'm just missing again? I have no problems on any other projects developed from same branch.
-
Thanks Ryan! Man I was struggling with this but once I got the logic everything went smoothly. I totally agree with what you said about arrays in GET vars. Now after form submission they are really ugly since it's submitted as is. Things get better when you move to different pages. Maybe I should send form by jQuery so I could make prettier urls by default or how would you do it? I did GET var whitelisting like this - pretty much as you suggested: <?php // open new instance of our import module since // it holds field names and types we can use for validation $deco = new DecoImport(); // there's some get data if ($input->get->count() > 0) { foreach ($input->get as $key => $value) { // skip undefined fields if (array_key_exists($key, $deco->fieldTypes)) { // skip empty values if (empty($value)) continue; // sanitize key $key = $sanitizer->selectorField($key); // sanitize value if ($deco->fieldTypes[$key] == 'page') { if (is_array($value)) $dirty = $value; else $dirty = explode("|", $value); $value = array(); foreach($dirty as $id) $value[] = (int) $id; // sanitize to INTs $value = implode("|", $value); } else $value = $sanitizer->selectorValue($value); // whitelist data $input->whitelist($key, $value); } } }
-
Thank you very plenty Ryan! You're absolutely right - I made such a rookie mistake and didn't have page numbers enabled from template setup. Once I did it paging started working like excepted. Sorry about that. Right now I have function that makes selector string for PW from post or get data and I have this excactly problem with PW page field values that it can be either array or string, with values separated by plus sing or empty space. If I just whitelist data like you suggest, I wouldn't have to do all checking and exploding at all. If I got this right.. Will test it later since it's my birthday and midsummer festival here in Finland so God Bless PW and hyvää juhannusta to everybody!
-
Aah, ok.. now it's looking better. Thanks! Still not there yet.. Now pager url looks like this: http://domain.com/search/?vendor=1087|1212&light_source_amount=&product_family=&safety_class=&voltage=&height_min=&height_max=&length_min=&length_max=&width_min=&width_max=&depth_min=&depth_max=&hanging_height_min=&hanging_height_max=&diameter_min=&diameter_max=&page=2 Notice pipes as vendor delimiters. OK, then I click to page 2 but nothing happens. Same results and pager page 1 is active. Only difference is that now pager urls have changed to use plus sign as delimiter: http://domain.com/search/?vendor=1087+1212&light_source_amount=&product_family=&safety_class=&voltage=&height_min=&height_max=&length_min=&length_max=&width_min=&width_max=&depth_min=&depth_max=&hanging_height_min=&hanging_height_max=&diameter_min=&diameter_max=&page=2 Selector for results remains same all the time: id>1, limit=20, template=product, vendor=1087|1212
-
Hello guys, need a little help here. I'm also trying to set pager for search results but the whole query string seems to be stripped out in links that pager renders. // page url http://domain.com/search/?vendor[]=1087&vendor[]=1212&light_source_amount=&product_family=&safety_class=&voltage=&height_min=&height_max=&length_min=&length_max=&width_min=&width_max=&depth_min=&depth_max=&hanging_height_min=&hanging_height_max=&diameter_min=&diameter_max= // pager urls http://domain.com/search/?page=2 http://domain.com/search/?page=3 http://domain.com/search/?page=4 Can it be because the query string is so freaking long?
-
Interesting grids - calculate your own widths.. It's like you would get gun and hunting cap from meat store.
-
To me, grid has to be cofigurable - otherwise it's probably too limited for everyday use. When I can adjust number of columns, gutters and paddings, I know I can use my grid basicly on every project, no matter who designs it.
-
I've also been looking to Susy direction but I like to do my preprocessing with php so that it runs on every server. If I need to quickly change some styles on live site I wan't to do it hassle-free. With LESS I use Leafos lessphp - he also has nice SCSS php compiler but it doesn't handle SASS syntax. Leafos lessphp is connected to my assets compiler class that generates minimized js/css files on the fly so it also handles preprocessing while doing it's job. How do you guys work with preprocessors? And does anyone have recomendations for solid php SASS parser?
-
Can I use Pro Cache in the pages where I need get parameters from url to modify output?
-
960.gs was the one that really kicked in then back in the days - for me and many others. I liked it so much that when I decided that we need to build our own fluid grid system, it had to be based on 960 syntax and be fully compatible with ancestor. BFluid was born. Since then it's been my one and only choise for css grid. Why to build own css grid when world is full of them? Simple - they don't bend the way you want. Most are based on fixed column count and don't support gutter + padding in cells. I also hate to have axtra markup for every row or extra class names for first/last items. BFluid is build on LESS so you can create custom grids on the fly. And have as many or as little of columns as you need - with gutter and padding. Nesting, multiple grids, fixed grid, semantic markup - it's all there. All we would need is some spare time to build cool site for it - or at least decent documentation. Maybe this summer..
-
Congratulations and thubs up for CMS Critic! Site is amazingly fast. Gotta get pro cache immediately.
-
I think you're right Ryan but maybe logic shoud be coherent all the times when 404 page is rendered. Consider this kind of scenario (that's used in this particular project). You've translated homepage name to match your language setup so every page has language identifier prefixed in url: domain.com/en/products/ domain.com/de/produkte/ domain.com/se/produkter/ Then if you enable url segments in this product template and handle false matches by throw new Wire404Exception(): domain.com/de/produkte/somefalsepath/ // here 404 page is in german when 404 is thrown manually from template domain.com/de/somefalsepath/ // here 404 page is in default language when system throws it It would be more logical if 404 page has same language in both cases.
-
OK, so maybe I just wrap values manually and forget sanitizer here. Sounds like easiest option. Page field would of course be the best solution for 'socket' but customer wanted text field for some reason so we have to deal with that. There's also lots of overhead when you have to get all data from actual product pages compared to that there would be individual pages for each socket type to be used as Page type 'socket' field.