Jump to content

Robin S

Members
  • Posts

    4,931
  • Joined

  • Days Won

    321

Everything posted by Robin S

  1. @kixe, when I try this (or use a hook to dynamically select a pages_id) there is always an option preselected in the inputfield. My SelectExternalOption field is not set to 'required'. Is it possible to have the first option in the inputfield blank (no selection)?
  2. If Language Support is installed but no additional languages created then there is a PHP error: PHP Warning: Division by zero in ...\FieldtypeSelectExtOption.module:504 Probably not something that happens very often.
  3. Not only "the processwire way", but also the way that is demonstrated in the documentation: foreach($page->test_matrix as $item) { if($item->type == 'blockquote') { echo " <blockquote> <p>$item->quote</p> <cite>$item->quote_cite</cite> </blockquote> "; } else if($item->type == 'bodycopy') { echo " <h2>$item->title</h2> $item->body "; } else if($item->type == 'gallery') { // and so on... } }
  4. Yes! I had forgotten about your thread there. That is still a work in progress and not released yet, right, or did I miss it? I think AOS and Tracy are the main modules where I find myself wanting a quick way to sync settings, but would definitely be cool to have that available for any module.
  5. Okay, thanks for the info. It would be neat if there was a feature allowing to export/import (copy/paste) the settings JSON without needing to uninstall/reinstall. As new AOS features are rolled out quite regularly (which is awesome) I often want to synchronise my new settings across many sites.
  6. I have tracked the issue down to the "Tooltips" submodule - when this submodule is disabled the Configure anchor links scroll to the wrong place (in the default Admin theme anyway). BTW, have been meaning to ask this for a while: is it possible to use the "Restore settings on next install" feature to copy AOS settings from one site to another? Or some other way to quickly replicate AOS settings on another site?
  7. This syntax works fine for me with plain Repeater fields, so it should work for Repeater Matrix fields too: $results = $pages->find("my_repeater.my_nested_repeater.my_textarea%=foo"); So maybe typos are slipping in somewhere else... Testing this did expose a bug where pages are matched when the repeater fields are empty - will file this at GitHub shortly. Done: https://github.com/processwire/processwire-issues/issues/205 There is another way you could do this, but I think the selector with subfields is more elegant... // returns the root container page for any repeater item no matter how deeply nested function getRootContainer($page) { if($page instanceof RepeaterPage) { return getRootContainer($page->getForPage()); } else { return $page; } } $results = new PageArray(); $repeater_pages = $pages->find("my_textarea%=foo, has_parent=2, include=all"); foreach($repeater_pages as $repeater_page) { $results->add(getRootContainer($repeater_page)); }
  8. Hi @tpr, would it be possible to get the field edit links that show on hovering a field label to work on fields that are inside repeater items? Ooh, and another idea re: field edit links. What if Ctrl-click brought up the settings for the field in the template context? (i.e. the template overrides) Edit: one more thing... The "Configure" anchor links in the Submodules panel do not scroll me to the right options panel, but scroll down quite a bit further. Tested in Firefox and Chrome on Windows.
  9. I think @ryan is unlikely to switch from region attributes in tags to a different system where regions are defined using HTML comments, considering that the Markup Regions feature is already published and currently being used in its existing form. But I do agree with your request to support a region tag that is stripped out of the final output. As you noted, that would be particularly useful for defining multiple regions inside the <head> element. There is a GitHub feature request that covers some of this stuff: https://github.com/processwire/processwire-requests/issues/78
  10. I think you need to set output formatting false before you start setting values to fields: $payment = $pages->get('template=payment,id='.$payment_id); $payment->of(false); if($payment->id) $payment->payment_status = P_PAID; $payment->save();
  11. Yes, the first blog post on the feature says that for now it must be explicitly enabled in $config: $config->useMarkupRegions = true; You have to be deliberately using the feature too in order to be affected by the stripped comments. So contrary to what I said above it isn't so much that useMarkupRegions is enabled, it's when there are comments in the HTML that occur before the doctype or <html> tag. ---- _main.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title><?= $page->title ?></title> </head> <body> <?= $my_var ?> <!-- this comment will be rendered --> <div id="main"> <p>Default main content.</p> </div> </body> </html> home.php <?php $my_var = " <!-- this comment will be rendered --> <p>hello</p> "; ?> <!-- this comment will not be rendered --> <div id="main"> <!-- and this comment will also not be rendered --> <p>Main content from home template.</p> </div>
  12. I have ProCache disabled from the main "ProCache enabled?" checkbox, which turns all ProCache features off including minification I believe. I uninstalled ProCache to be sure and did a bit more testing. Seems to be an unannounced side-effect of the Markup Regions feature. When this is enabled in config.php all HTML comments both inside and outside a markup region in a template file are stripped out of the compiled output (edit: clarified below). I don't mind that as it's useful to be able to put notes and separators into the markup that are better kept out of the front-end source. I was just a bit surprised as this wasn't mentioned in the blog posts.
  13. You are spot on - I have the ProcessWire namespace declared everywhere except in my included file. Thanks!
  14. I just noticed that HTML comments in a template file are not rendered in the front-end source. Which is totally fine with me, very useful in fact, but I'm wondering what part of PW is responsible and when this started happening. I know that ProCache strips HTML comments, but I don't think that is the cause in this case because I currently have it disabled and comments are still not rendered. Was it introduced by the file compiler starting in PW3? Or maybe part of the new Markup Regions feature (which I have enabled) ? Or has this always been the case and I just never noticed? To be clear: HTML comments in _main.php are rendered, just not those in a template file. Wrong forum section sorry. Meant to post this in General Support.
  15. There is probably an obvious answer to this but I am suffering a brain-fade: In my auto-prepended "_init.php" I have a function defined... function myFunction() { echo "hello!"; } I can use that function in my auto-appended "_main.php" or in a template file (e.g. "home.php") no problem. But why is it undefined if I call it in a file that is included in _main.php or home.php? include "./my_include.php"; my_include.php // results in "Call to undefined function myFunction()" myFunction(); I was expecting _init.php to have been prepended by the time myFunction() is called inside my_include.php - or does my_include.php get included before _init.php? I guess I'm not clear on the order of operations here. Do I have to include _init.php inside my_include.php, or is there some other simple way to make myFunction() available globally?
  16. Yes, the full rule is... #ProcessListerResults select, #ProcessListerResults textarea, #ProcessListerResults input[type="url"], #ProcessListerResults input[type="email"], #ProcessListerResults input[type="text"] { width: 100%; } ...in ProcessPageListerPro.css So you could override that specific rule or use a more generic rule like in my previous post to try and force the filterbox input to always be width:auto - whichever you think best. Thanks.
  17. @tpr, I noticed that the filter box icon is out of alignment on Lister Pro pages. Not sure if you have Lister Pro available to test on but the culprit is a CSS rule that sets text inputs to 100% width inside #ProcessListerResults. Maybe force the width back to auto for the filterbox? html.aos div.filterbox input[type="text"] { width:auto !important; }
  18. In case you're not using it already... Tracy Debugger is a must-have for debugging.
  19. Welcome to the forums, @danielsl! You could do this: $p = $pages->get('/advert_page/'); $repeater_names = $p->fields->find('type=FieldtypeRepeater')->explode('name'); foreach($repeater_names as $repeater_name) { foreach($p->$repeater_name as $item) { // output your repeater item } } If you have repetitive markup that is used in several places also remember that you can put it an in an include to avoid repeating yourself.
  20. Maybe you don't want to do this, but wouldn't it be easier to build real PW pages from the external data using a cron job? Then you would have the all the PW API benefits for those pages.
  21. To introduce some other API methods you may not have tried yet... // different way of matching subfield, and using simply $page $kisiler = $pages->find("template=kisi, sort=title, repeater_ozlusoz.ozlusoz_konusu=$page"); foreach($kisiler as $kisi) { // you can use find() on your repeater PageArray $aforisms = $kisi->repeater_ozlusoz->find("ozlusoz_konusu=$page"); foreach($aforisms as $key => $aforism) { // another way to get a numbered index // but maybe you should consider using ordered list markup instead? $num = $key + 1; // getting a string from a PageArray using the implode() method // and better to space your items with CSS than hardcode non-breaking spaces $tags = $aforism->ozlusoz_konusu->implode(' ', '<a href="{url}">{title}</a>'); echo "<p>$num. <a href='$kisi->url'>$kisi->title</a>: <i>$aforism->ozlusoz</i><br>Etiketler: $tags</p>"; } echo "<hr>"; }
  22. Yes, correct on both. One advantage of the Connect Page Fields module is that it can make the generation of your tags page more efficient. How much so depends on what you want to show on the tags page. To explain... For a page like the screenshot from @Sérgio, with a count next to each tag link, the typical way using only common API methods would be something like: $tags = $pages->find("template=tag, sort=title"); foreach($tags as $tag) { $count = $pages->count("tags=$tag"); // count how many pages have this tag selected // now output the tag link and count } And if you happened to want to list the articles that use each tag underneath that tag you would do something like: $tags = $pages->find("template=tag, sort=title"); foreach($tags as $tag) { $tagged_pages = $pages->find("tags=$tag"); // find pages that have this tag selected // now output the tag and the list of pages } A $pages->count() has less overhead than a $pages->find(), but it's still a lot of DB queries if you have a lot of tags. You'd probably want to cache this if you did it this way. With Connect Page Fields, the pages that use the tag are stored in a Page field so you can easily get a count or the pages themselves directly: $tags = $pages->find("template=tag, sort=title"); foreach($tags as $tag) { // you probably wouldn't bother assigning these to variables but just for demonstration $count = $tag->articles->count(); $tagged_pages = $tag->articles; // output your tag, count, etc } And for one more option involving a single SQL query on the tags table see this:
  23. @j00st, you might like to take a look at the Connect Page Fields module: Once the module is installed it takes care of keeping the fields in sync but if you already have your articles(?) tagged you would write some API code for a one-time operation to iterate over your article pages and add them to the selected tag pages.
  24. Not sure why that is happening, but just to let you know that address works fine for me. Could some browser extension be interfering perhaps?
  25. @Beluga, I think the ImportPagesCSV module should be able to handle 35K rows with the right PHP settings. Ryan has talked about needing to split into batches above 450K rows (!) so 35K should be no problem.
×
×
  • Create New...