Jump to content

Tyssen

Members
  • Posts

    354
  • Joined

  • Last visited

Everything posted by Tyssen

  1. I want to be able to use the page that a user is assigned to do other things in my templates. If I do this: $ap = $user->editable_pages; echo $ap; I get a number output. But if I do this: $lp = $pages->get($ap); echo $lp->title; I get an error: Unknown Selector operator: '[empty]' -- was your selector value properly escaped? If I hard code the actual number from echo $ap in the get selector then I get the output I'd expect. What do I need to do to $ap recognised as a PW page object?
  2. Ah, that's an interesting idea and probably less work than what I had in mind, lol. Except in my case, the member group is assigned to a portfolio page via a page reference field, rather than being assigned to the user. And the user is given edit access to his/her page with the Page Edit Per User module. I can still work out which member group page a user is associated with, it just won't be as straightforward as using hasRole.
  3. I've been brought in to work on a site which allows members to upload images to display on their profile page. The number they can display is limited by the member group they're in. Currently, the limit is only applied on output, not on input. The same image field is available to all members so they're all getting the same upload limit.. I'd like to change it so that each member group has its own images field and each field has the upload limit set to the limit for that group. I know I can use field dependencies to show the correct image field depending on which member group they choose. But how do I get the existing images that are attached to the current all-in-one images field into the new member group-specific image fields?
  4. I've just installed Valet and have been testing sites running a few different CMSs including PW, Craft and ExpressionEngine. The sites on Craft and EE work fine, but for one of the PW sites I created, I get the home page on every URL I visit, and the other, the home page works OK, but every other page gives me a 'The page isn’t redirecting properly' error. Actually, it's every other PW page, i.e. one ending with a / If I try and visit a non-existent page like example.html, I get the 404 page for the site. Is there something else that needs to be done to PW sites to get them to work with Valet?
  5. I've added a function to my _init file but found it wasn't working until I added a namespace to _init and any other file calling a function from _init. But on one template I've got new SimpleXMLElement which is causing the 'class not found error' which appears to be due to the namespacing. What do I need to do to solve that?
  6. @gmclelland Must've been something wrong with the export of the db from my local. I renamed MarkupSEO and then it threw the same error for FormBuilder. Renamed it too and then the admin page came up but using the default theme and it was reporting that modules had been downgraded to earlier versions. Ran another export/import and it's all fine now. ?
  7. @flydev I still get the same error. I should also mention that this staging site was working fine until the latest changes.
  8. I've been working on a site locally and wanted to upload some changes to a staging site but after exporting the site's database and reimporting to the staging site and uploading the changed files, I can no longer access either the front or back end of the site. Instead I get: I've tried deleting the contents of site/assets/FileCompiler but that didn't help. What else do I need to do to get the site back?
  9. Actually it is. I've just checked wire/core/Fields.php and the added lines from the commit you linked to are already there.
  10. I've upgraded PW to 3.0.141 and the module to 0.9.0 but still get the same error I reported on the previous page when accessing a page which has the field in its template.
  11. That solves the editing of the field problem, but if I visit a page which has the field on it, I get:
  12. Sorry, I had Use parent's values if empty checked previously and those fields didn't show until I unchecked it. All good now. ?
  13. Just encountered the same.
  14. I've tried updating with your fork Adrian, but it doesn't seem to. Also, after updating Use parent's values if empty doesn't work.
  15. Is there a way for the SEO Title field to automatically be filled in with the Page Title if it's left blank?
  16. Figured it out in the end. Coded above would work fine, but I had other conditionals in place which were preventing parts of it from running.
  17. I'm working with an XML feed which provides image URLs that I want to save to an images field in a repeater. So far I have this: foreach($page->goodreads as $goodreads) : $xml_string = $cache->get($goodreads->isbn, 3600, function() use($goodreads_api, $goodreads) { return curl_get_contents('https://www.goodreads.com/search/index.xml?key='.$goodreads_api.'&q='.$goodreads->isbn); }); $book_xml = new SimpleXMLElement($xml_string); foreach ($book_xml->search->results->work as $book) : $goodreads->of(false); $goodreads->images->add($book->best_book->image_url); $goodreads->save(); $goodreads->of(true); endforeach; endforeach; I've tested that $book->best_book->image_url does actually return a value and have also tested the above with a hard-coded image URL but in both cases, no image is saved. What am I missing?
  18. I have a page that contains a single ProFields table field and I want to display the contents of the table on the front end and then for logged in users, they can edit certain columns in the table. What I have at the moment is $out = '<form action="'.$page->url.'" method="post" > <table class="table"> <tbody>'; $count = 1; foreach($page->fieldName as $row) : $out .= ' <tr> <td><input type="checkbox" name="fieldName_'.$count.'_columnName"></td> </tr>'; if($input->post->submit) : $page->of(false); $page->set('fieldName_'.$count.'_columnName', $sanitizer->text($input->post->{fieldName_'.$count.'_columnName})); $page->save(); endif; $count++; endforeach; $out .= ' </tbody> </table> <button class="button" type="submit">Save</button> </form>'; The two problems I have are: I get an error trying from $sanitizer->text($input->post->{fieldName_'.$count.'_columnName}), not sure how to make that dynamic. If I change the above to just a static value, e.g. $page->set('fieldName_1_columnName', 'Testing') and save the form, it's not saving the values to the database. Where am I going wrong?
  19. Actually never mind, set it as a variable in _init.php and then call it in the twig template.
  20. Another question: in Twig how would you call modules like AIOM where in PHP it'd be <?=AIOM:CSS(array())?> or <?=AIOM:JS(array())?> ?
  21. I've obviously missed something, because I'm getting Call to a member function render() on null from _main.php. My templates are… _init.php <?php $twig_main_dir = $config->paths->site . 'templates/views'; $twig_loader = new \Twig\Loader\FilesystemLoader($twig_main_dir); $twig_env = new \Twig\Environment( $twig_loader, [ 'cache' => $config->paths->cache . 'twig', 'debug' => $config->debug, 'auto_reload' => $config->debug, 'strict_variables' => false, 'autoescape' => true, ] ); if ($config->debug) { $twig_env->addExtension(new \Twig\Extension\DebugExtension()); } foreach (['page', 'pages', 'config', 'user', 'languages', 'sanitizer'] as $variable) { $twig_env->addGlobal($variable, wire($variable)); }; $twig_env->addGlobal('homepage', $pages->get('/')); $twig_env->addGlobal('settings', $pages->get('/site-settings/')); $variables = []; _main.php <?php $template_file = 'views/' . $page->template->name . '.twig'; $twig_template = file_exists($twig_main_dir . '/' . $template_file) ? $template_file : 'views/basic-page.twig'; echo $config->twig_env->render($twig_template, $variables); My .twig templates are set up as yours are and my PW .php templates are just blank at the moment.
  22. So I think I got it. I had to add this to package.json under globs. "critical": [ { "url": "", "template": "home" }, { "url": "url-using-this-template", "template": "basic-page" }, { "url": "blog", "template": "blog" }, { "url": "blog/blog-post-url", "template": "blog-item" }, { "url": "contact", "template": "contact" } ],
  23. I'm working on a site that uses the front-end tooling set-up from https://github.com/nystudio107/craft It uses package.json for defining all the Gulp plugins and paths as described in https://nystudio107.com/blog/a-better-package-json-for-the-frontend I've been able to convert it for use with my Processwire project but I'm a bit confused about how the Critical CSS part works and how to map URLs to templates. I've also found https://processwire-recipes.com/recipes/inline-critical-css/ which uses Grunt but again, it's not clear to me how it handles all the templates. Has anyone got a similar set up working and would you be able to share your package.json or gulpfile?
×
×
  • Create New...