Jump to content

Robin S

Members
  • Posts

    4,931
  • Joined

  • Days Won

    321

Everything posted by Robin S

  1. The PW htaccess only blocks direct access to PHP files inside /site/ Anything outside of /site/ should be accessible.
  2. That isn't valid syntax for whitelist(). See the docs: https://processwire.com/api/ref/wire-input/whitelist/ The syntax is valid here, but you'll be overwriting the same whitelist key in each iteration of your loop. I think you want to set an array to the whitelist key, e.g. $san_array = array(); foreach($input->get->st as $st) { $san = $sanitizer->selectorValue($st); $san_array[] = $san; $selector .= "projectStatus=$san, "; } $input->whitelist('st', $san_array); // later, call renderPager() with arrayToCSV set false // or do as Ryan suggests: https://processwire.com/talk/topic/1883-how-to-use-input-whitelist-with-checkboxes-or-any-array/?do=findComment&comment=17706 echo $works->renderPager(array('arrayToCSV' => false)); For the other issue regarding setting the selected attribute of the checkbox you'll want to use in_array.
  3. A similar topic with some solutions:
  4. @Mike Rockett, thanks for the info. I asked my host about Let's Encrypt certificates and they said they been providing free SSL certificates for all accounts for the last three months. Must have missed the announcement. Looks like the certificate is by Comodo via cPanel. Not sure what the pros and cons are versus a Let's Encrypt certificate but a check on SSL Labs gave it an "A" so sounds good enough to me.
  5. That sounds great. Who do you host with, and do they publicly promote this on their website? Are they a cPanel host running the Let's Encrypt plugin? Am going to try and convince my host to do the same, and may consider moving host if they won't play ball.
  6. You pass $page to the render method in the $options array. From the post I linked to above:
  7. IMHO this should be the default behaviour of a PageTable field. Having the PageTable pages as children of the page is confusing for editors and I've never understood the reasons why that should happen as the default.
  8. Using render() as kongondo suggests is good - here is some info from Ryan on the available options. But I usually output from a PageTable the same way as I would a Repeater, e.g. if page_table_field is in the "basic page" template, in basic-page.php... foreach($page->page_table_field as $p) { echo "<h3>{$p->title}</h3>"; // etc, for other fields in the PageTable item template }
  9. Any clue how I could start that ? If the module is a Process module you can create and require a custom permission in the module info (that is, getModuleInfo(), etc). See the ProcessHello module for an example: https://github.com/ryancramerdesign/ProcessHello/blob/9c1aa18eb40d069c7fb227f09badddc90f0b3276/ProcessHello.info.php#L33-L39
  10. Another way... adapt this SQL query by Ryan: $table = $fields->get('my_page_field')->getTable(); $query = $database->query("SELECT data FROM $table"); $ids = $query->fetchAll(PDO::FETCH_COLUMN); $count_values = array_count_values($ids); // use the pages IDs and counts as needed, for example: foreach($count_values as $key => $value) { $p = $pages->findOne($key); echo "<p>{$p->title} (selected in $value pages)</p>"; }
  11. There is no built-in method to do this efficiently in PW - to use normal selector queries you would need to iterate over all tag pages, for each tag counting the pages that have that tag selected, then sorting by count. This is one of the things that prompted the Connect Page Fields module
  12. You shouldn't need to do anything special to get pagination to work with search results. Make sure you have page numbers enabled for your search template: Your pagination links (2, 3, 4, etc) should include the GET query string (e.g. "/search/page2?search=foo&year=1985") - do they in your case?
  13. You can do this: $failed_files = array(); foreach($items as $item) { if(file_exists($fileurl)) { $item->scheda_tecnica = $fileurl; $item->save(); } else { $failed_files[] = $fileurl; } } // when finished, echo/log the contents of $failed_files
  14. Hi @Federico, welcome to the PW forums. I'm not really clear about what you're asking but here goes... You want an array of all GET variables? You can get that by using $input->get() without any argument. foreach($input->get() as $key => $value) { // sanitize each $value as needed, etc } But you probably don't want to treat each variable the same, pass it through the same sanitizer, etc. So I think it's more typical to check for the exact named variables you are expecting and ignore anything else that might be there. So for example, for "year" you are expecting an integer so you would apply $sanitizer->inUnsigned(). P.S. take a look at the search template for the Skyscrapers demo - it's a really good demonstration of the basic principles.
  15. That's a namespace problem - for some reason your template is not being compiled with the ProcessWire namespace. You can add the namespace... $comments = ProcessWire\FieldtypeComments::find("comments", $selector); ...but you shouldn't call the find() method statically anyway. The comment block for the deprecated findComments() explains how the find() method should be called: @deprecated Use $field->type->find($field, $selectorString) instead.
  16. I don't know much about GraphQL but I want to learn more, and your module looks like it will make it easy to get started with in PW. So definitely interested.
  17. Isn't it just a stylistic preference whether you increment the counter at the beginning or the end of your operations?
  18. Nice. Those UIkit PHP functions will be a real bonus for anyone using the profile as the starting point for a website. I like the dummy text - what generator did you use?
  19. What you're describing is an issue about convenience and workflow in the admin. You have some pages that you want to view as a group with some kind of separation from the other pages. There are better ways to deal with this besides changing the page structure in the tree. The solution that I like best is Lister Pro - you pre-configure a Lister Pro instance for each group of related pages and then you or your editor can work with these pages without the distraction of other pages. And the interface is much more powerful than the page tree, especially when you start working with Actions and inline editing. For a no-cost solution you could: 1. Work with the core Find lister - it's pretty quick to filter by template or whatever to see your related pages. 2. Put together a simple Process module to live in the menu under "Pages". For example: class ProcessMyPages extends Process { public static function getModuleInfo() { return array( 'title' => 'My Pages', 'summary' => 'An example of a Process module that lists pages.', 'version' => 1, 'permission' => 'page-edit', 'page' => array( 'name' => 'my-pages', 'parent' => 'page', 'title' => 'My Pages' ), ); } public function execute(){ $table = $this->modules->get('MarkupAdminDataTable'); $table->setEncodeEntities(false); // headers $table->headerRow( array('Title', 'Modified', 'Created', 'Created by') ); // find the pages you want to list $my_pages = $this->pages->find("template=news_item"); foreach($my_pages as $page){ // create whatever columns you want $data = array( "<a href='{$this->config->urls->admin}page/edit/?id={$page->id}&modal=1' class='pw-modal'>{$page->title}</a>", date("j F Y", $page->modified), date("j F Y", $page->created), $page->createdUser->name, ); $table->row($data); } return $table->render(); } }
  20. Publishing/unpublishing via a cron job is probably the way to go if you have many different templates that you want to limit the availability of based on date/time. But where I only have one or two templates that I need to control this way (e.g. news items) I just code the limits directly into the template files rather than publish/unpublish. So in the news item template I check if the current date is within the start/end dates and throw a 404 if not. And in news listings I include the date check in the $pages->find() selector. This approach works well if you want fine-grained control of page availability (e.g. make pages available/unavailable down to the minute or second) and don't want a cron job running that frequently.
  21. I think kongondo might be referring to the upgrade() method. From the docs: So in your module upgrade method you can do something like: // Upgrade from < v0.0.5 if($fromVersion < 5) { // do something }
  22. Thanks - I wasn't aware of that system tab before. I'm sure Ryan must have had a reason for disabling the trashing of user pages by default but in testing so far it seems okay. I had to uncheck the "Don't allow pages to be moved" option for the user template too in order to allow trashed users to be restored.
  23. You could use a hook to force a sort order on the Repeater field. See here: To prevent drag reordering you can use the Limit Repeater module: Not sure about opening a particular Repeater item when Page Edit loads - maybe have a look at the Repeater module code to see how the "Remember which repeater items are open" option is implemented. Alternatively you could use child pages instead of a Repeater for the band bios. This would allow you to define a sort setting for child pages of the band template in admin. Then use a RuntimeMarkup field to create: a list of modal edit links to the child pages, which will open about as fast as an ajax-loaded Repeater item a (truncated?) summary of the bio for the most recent child page an "Add new" button for easily adding a new child page
  24. Users are pages, but for some reason unlike other pages it seems that they skip the trash and are permanently deleted. Is there some trick to allow users to be trashed rather than deleted? I need to give an editor role the ability to remove users but sometimes they "change their mind" and want to recover a user that they previously deleted.
×
×
  • Create New...