-
Posts
5,008 -
Joined
-
Days Won
333
Everything posted by Robin S
-
Just a correction to this (from the docs):
-
[SOLVED] 403 Forbidden when loading images from folder
Robin S replied to jploch's topic in Getting Started
PW blocks direct access to PHP files within /site/ Alternatives are to place your PHP file outside of /site/ (e.g. in the root directory) or to use a PW template/page to respond to your AJAX request. The latter would be nice solution in this case because you could use an images field in the template to hold your animation images. -
I spent my first seven years of life in Canvastown and have fond memories of that area (Pelorus Bridge especially). A beautiful spot.
-
Searching for numbers throws Exception: Operator '~=' is not implemented
Robin S replied to joe_ma's topic in General Support
Got it. If you have ProFields then Table could be a good alternative to a Repeater that avoids the overhead of extra pages. A PageArray is not a type of field, but several fieldtypes return their value as a PageArray. Repeater, PageTable and "multiple" Page Reference fields all return PageArrays. I think you are meaning a Page Reference field. If so, did you manage to get it working? I tested it and you should be able to match the title of a page inside a Page Reference field inside a Repeater with: authors.authors_name.title%=$q_word -
You could use WireArray::getValues() to get a regular array (with a zero-based index) of your team players: $teamPlayersArray = $teamPlayers->getValues(); Edit: another possibility that keeps the team players as a PageArray: $teamPlayersReindexed = new PageArray(); $teamPlayersReindexed->import($teamPlayers);
-
I think that is because in that example you are adding files to the repeater page. A page has to be saved before you can add files or images to it.
-
Your code copied from the GitHub issue: $options = wirecommerce_get_all_variations($page); $variations = $page->wirecommerce_variations; // Detect added $added = 0; foreach($options as $option) { if(!$variations->has("wirecommerce_variation_value='$option'")) { $new_option = $variations->getNewItem(); $new_option->wirecommerce_variation_value = $option; $new_option->save(); $added++; } } if($added > 0) $this->message("$added variations added."); The code example for adding a repeater item from the documentation: $building = $page->buildings->getNew(); $building->title = 'One Atlantic Center'; $building->feet_high = 880; $building->num_floors = 50; $building->year_built = 1997; $building->save(); $page->buildings->add($building); $page->save(); So I think your code should be: $options = wirecommerce_get_all_variations($page); $variations = $page->wirecommerce_variations; // Detect added $added = 0; foreach($options as $option) { if(!$variations->has("wirecommerce_variation_value='$option'")) { $new_option = $variations->getNew(); // Or getNewItem(), they are the same thing $new_option->wirecommerce_variation_value = $option; $new_option->save(); $variations->add($new_option); $added++; } } $page->save(); if($added > 0) $this->message("$added variations added.");
-
I think Ryan is talking about setting the sort on the parent page of the repeater page, not for a template. So you locate the parent page under Admin > Repeaters and set a sort on the Children tab. But... this doesn't work because when setting an automatic sort like this it doesn't actually change the "sort" value of the pages in the database, which is what a repeater field uses to determine the sorting within the inputfield. A related post that might be useful:
-
@alan, you might be better off using a mod_rewrite rule than using Redirect, because then you can use the [L] flag to avoid the other rewrite rules affecting the URL. So instead of... Redirect 301 /my-short-cut http://example.com/the/long/page/to/go-to/#theAnchorIwant ...try... RewriteRule ^my-short-cut$ http://example.com/the/long/page/to/go-to/#theAnchorIwant [R=301,NE,L] ...just after... RewriteEngine On
-
How do you mean? The test is if the user doesn't have the permission then the contenteditable attribute does get removed.
-
@gmclelland, turns out it is a piece of cake with str_replace. Create a custom permission "rename-images" and give that to roles that you want to allow to rename images. Then add the following to /site/ready.php $wire->addHookAfter('InputfieldImage::renderItem', function(HookEvent $event) { if(!$this->user->hasPermission('rename-images')) { $event->return = str_replace(" contenteditable='true'", "", $event->return); } });
-
Sure, but I suspect that if you look at the code that creates the inputfield markup there will be nothing hookable that lets you change that attribute in isolation. And it might be a long time before such a thing gets implemented in the core given the number of existing feature requests. Often you just have to do what you can to solve this kind of thing yourself. Edit: if there's nothing else in the inputfield with the contenteditable attribute apart from the name fields you might be able to do a string replace on the markup returned from InputfieldImage::render to strip out that attribute. Pretty hacky but no more so than the JS approach I guess.
-
An idea on how you could achieve this: Add a body class in admin according to the user's role: This has also been added to AdminOnSteroids if you are using that. Then add a custom javascript to ProcessPageEdit that selects .InputfieldImageEdit__name inside a particular body class and removes the "contenteditable" attribute from the inner <span>. You'd put this into a function and have it fire on domready and ajaxcomplete events.
-
@gmclelland, I just figured it out by clicking around as you replied. Cool, I had no idea that was possible!
-
How do you rename images through the admin UI? I wasn't aware that was possible.
-
The login details for your superuser account must be coming from somewhere. One place they might be coming from is your browser in the form of a saved login. Do you get the same problem if you access this page from a different browser that has never been used to login to your superuser account? In this line here... if(/* !$user->isLoggedin() && */ $input->get->confirmcode && $input->get->confirmcode == $session->get("confirmcode")){ ...I see that the check to make sure the user is not already logged in is commented out. So I wonder if you might already be logged in as superuser at this point. Does your header or footer contain a login form that might be getting auto-filled with your superuser login details?
-
I don't think WireException is involved there. What you are seeing is a fatal error message from PHP, and you can't "catch" a fatal error AFAIK.
-
Last night a documentary called "Steve Jobs: The Lost Interview" was broadcast on New Zealand television (on Maori Television, which is about the only free-to-air channel worth watching here). Now I am very far from being an Apple fanboy and I knew almost nothing about Steve Jobs going in. I haven't seen any of the biopics from recent years. I was tossing up whether to even turn on the TV but thought I would give it a few minutes. Well, I was glued to the screen throughout and now I completely get why this guy was exceptional. He's obviously very intelligent but you expect that. What blew me away was the clarity of his thinking and the general manner in which he communicates. Here he is answering questions off-the-cuff and the answers he gives are so concise and insightful and just go straight to the crux of the issue. And when he is asked a question about something he hasn't previously clarified his own thinking on he doesn't just blurt something out like normal people - he pauses and thinks and then answers. That is a rare quality. This is 70 minutes of unedited interview but it is fascinating stuff. There are goodies in there for people interested in computer science history, but also highly recommended for anyone with an interest in management or even general self-improvement.
-
Hi @adrian, I struck a problem trying to use bd() inside $sanitizer->pageNameUTF8(). If I add a bd() call to pageNameUTF8() like this... public function pageNameUTF8($value) { bd($value, 'value'); //... ...and then trigger the method like this... $test = $sanitizer->pageNameUTF8('foo'); ...then everything is fine so far and works as expected. But as soon as I add the following to /site/config.php $config->pageNameCharset = 'UTF8'; ...then I get an error: Any idea why this happens?
-
Length of $input->urlSegment() limited to 128 characters
Robin S replied to Johannes Weberhofer's topic in General Support
Welcome to the forums @Johannes Weberhofer It looks like it isn't possible to increase the allowed length of a URL segment. This is because when a URL segment is set, the value is passed through $sanitizer->name() or $sanitizer->pageNameUTF8() depending on if $config->pageNameCharset = 'UTF8' is set. For $sanitizer->name() at least (I had some trouble debugging $sanitizer->pageNameUTF8) the maxLength option defaults to 128, and although that method allows a custom maxLength to be used there is no option to specify this for URL segments. I can't see why a URL segment needs to be limited to 128 characters and it would be nice to have the ability to set a higher max length. Maybe you could open a feature request at GitHub? -
When you deny view access to the guest role you can enter a URL to redirect to. In this field you can use {id} in a GET variable to track which page the user was trying to access.
-
You can do it just as shown here... But instead of hooking after Page::editable you hook after Page::addable.
-
Here is an attempt to simplify things a bit: $wire->addHookAfter('ProcessPageAdd::buildForm', function(HookEvent $event) { $form = $event->return; $template_select = $form->getChildByName('template'); $options = $template_select->getOptions(); $options = array('' => '') + $options; $template_select->set('options', $options); // Set the value to something that will never match an option in the select (any string will do) $template_select->value = 'a'; $template_select->attr('required', 1); }); It's important to set the HTML required attribute (thanks to @abdus for the idea) and to make sure none of the options get the "selected" attribute (hence setting the inputfield value to something that will never match an option). Otherwise if the Add New form is submitted with no actual template selected a nasty error occurs - the core does not allow for the possibility that no valid template ID is included in POST.
-
On the fields that you have set access restrictions for, on the "Access" tab try checking the checkbox shown below: