Jump to content

Robin S

Members
  • Posts

    4,772
  • Joined

  • Last visited

  • Days Won

    302

Everything posted by Robin S

  1. 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 }
  2. 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
  3. 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>"; }
  4. 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
  5. 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?
  6. 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
  7. 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.
  8. 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.
  9. 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.
  10. Isn't it just a stylistic preference whether you increment the counter at the beginning or the end of your operations?
  11. 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?
  12. 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(); } }
  13. 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.
  14. 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 }
  15. 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.
  16. 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
  17. 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.
  18. @adrian, a while ago @bernhard came up with a cool idea for a "hook recorder": I'm wondering if you and he think this is something that might be integrated into Tracy Debugger. Now that there is the feature in Tracy (thanks @owzim) for parsing the hookable methods from the wire/site directories, I was thinking that there could be a feature that temporarily appends hooks for all hookable methods to /site/init.php or /site/ready.php. These "auto-hooks" would just do something simple like log/dump the method name as the hook fires. Of course this would be terrible for site performance - it's something you would only enable briefly during development to work out which hookable methods are firing as PW completes some task. What do you think?
  19. If you haven't seen it already, check out the new Captain Hook panel in Tracy Debugger. If you have the Editor Protocol Handler configured you can jump straight to the hookable method in your code editor. Because the line links are generated from whatever PW version you are running it will always be correct. Pretty cool. Plus it includes the hookable methods in module classes!
  20. All fixed, thanks. I'm really liking how easy it is to jump straight to the method in my code editor via the clickable line number. A real timesaver.
  21. If I can make it like this above my css will be work perfectly but can't fixed yet.... Try setting this as part of your $options array: 'xtemplates' => 'home', 'xitem_tpl' => '<a href="#home">HOME</a>', 'xitem_current_tpl' => '<a href="#home">HOME</a>', By the way, you have many settings in your $options array that are identical to the defaults - these are unnecessary.
  22. I think that's because when you use your Hanna tag in CKEditor your audio attribute is (or should be) valid link markup, e.g. <a href="/some/url/">LINK</a> But in the Hanna Code test tab the attribute is not a valid link but simply the string "LINK" which cannot be parsed by SimpleXML. So probably nothing to worry about, but if the error message is a concern you can do some simple check to see if the attribute looks like it will be a link. For example, at the top of your Hanna code: if(substr($audio, 0, 2) !== '<a') return;
  23. Problem seems to be here: $paths = array($root); Might be misunderstanding something but don't think the root directory is wanted in that array.
  24. I'm seeing an error in the new Captain Hook panel on Windows - I think it's the path slashes issue. ErrorException: file_get_contents(D:/Websites/__www/1testing/wire/): failed to open stream: No such file or directory in D:\Websites\__www\1testing\site\assets\cache\FileCompiler\site\modules\TracyDebugger\CaptainHook\classes\CaptainHookSearch.php:44 Dumping $filenamesArray in CaptainHookSearch::getHooks() shows paths like... "D:/Websites/__www/1testing/wire/" "D:/Websites/__www/1testing/wire\config.php" "D:/Websites/__www/1testing/wire\core\admin.php" "D:/Websites/__www/1testing/wire\core\boot.php" ... Edit: actually, it might be the first item in the array that's the problem: "D:/Websites/__www/1testing/wire/". Seems like this shouldn't be in there seeing as it's a directory and and not a .php or .module file.
×
×
  • Create New...