Jump to content

Robin S

Members
  • Posts

    4,928
  • Joined

  • Days Won

    321

Everything posted by Robin S

  1. Thanks for the report @adrian. I have fixed this in v0.0.2. Now the Save + Add New button is not added when editing inside a modal, as I don't think it's desirable in those circumstances (another case of this is when editing a field's template context from the template editor).
  2. Does anyone know if there is a way to install a module via the "Add Module From URL" feature if the module is in a private repository? It's a GitLab repository in this case. When I try to do this it fails with: The URL is correct, but no doubt needs authentication to be accessed. Is there a way to supply username/password to allow the download?
  3. You can install the core LanguageSupport module and then "translate" the string for the Default language:
  4. The admin page always has the ID of 2 (as far as I know). So you can get the httpUrl with: $pages(2)->httpUrl()
  5. Another option for adding elements at the end of <head>: $wire->addHookAfter('AdminTheme::getExtraMarkup', function(HookEvent $event) { $parts = $event->return; $parts['head'] .= "<script src='/path/to/script.js'></script>"; $event->return = $parts; });
  6. I'll try that, thanks. Looking at that chunk of code, it's not about setting items to an uninitialised array with $paths[] = $path (which is okay) but if $iter is empty then $paths does not exist.
  7. Yeah, it's a Java app so it's not picky about OS or version.
  8. That's the organisation pricing. You're an individual customer so it's $89. And you don't need to pay anything beyond that. See the license details. The ongoing "subscription" is if you want to receive updates (sort of like the system with Ryan's Pro modules), but the reality is that an IDE is a glorified text editor - it's not like they're bringing out must-have new ways to edit text every other month. So you'll be fine with the current version for some years to come.
  9. Hi @adrian, What do you think about the idea of adding a filter search to the Captain Hook panel? Much of the time when I use this panel I know the name of the class and method I want to hook and I'm just wanting to check what the arguments are (and it's a handy way to jump to the method in my editor). Not sure how tricky that would be to implement. Even if it just worked on the top level (the file names) it would be cool.
  10. Welcome to the forums @Smoo. The markup is the content, but if you are seeing tags rendered like that then it could be caused by encoded entities. Check to make sure you do not have "HTML Entity Encoder" selected under "Text Formatters" in the field settings.
  11. FieldsetTab is not supported by the core "show if" dependency, but it turns out it is possible to support it in this module. Please update to v0.0.5.
  12. Perhaps some exception or PHP error is occurring. Do you have debug mode on or (even better) Tracy Debugger installed to make sure you see error messages?
  13. Let's do a comparison of how you would do this with the typical delayed output approach vs Markup Regions. When it comes to the Markup Regions example I'll do it a little differently than you've proposed it, with a dedicated <region> for scripts instead of appending to <head>. Delayed output _init.php $scripts = ''; _main.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <?= scripts ?> </head> //... template-which-needs-js.php if(strpos($page->name, 'special') === 0) { $scripts .= "<script src='{$config->urls->templates}assets/js/my-script_2.js'</script>"; } else { $scripts .= "<script src='{$config->urls->templates}assets/js/my-script_1.js'</script>"; } Markup Regions _init.php Nothing needed here because one of the nice things about Markup Regions is that you don't need to initialise a markup variable. _main.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <region id="scripts"></region> </head> //... template-which-needs-js.php <region id="scripts" pw-append> <?php if(strpos($page->name, 'special') === 0): ?> <script src="<?= $config->urls->templates ?>assets/js/my-script_2.js"></script> <?php else: ?> <script src="<?= $config->urls->templates ?>assets/js/my-script_1.js"></script> <?php endif; ?> </region> So comparing a markup region to a variable: Use pw-append where you would have used $some_var .= 'something' Use pw-prepend where you would have used $some_var = 'something' . $some_var Use neither pw-append nor pw-prepend where you would have used $some_var = 'something' But Markup Regions are even more powerful because you can have multiple nested markup regions in _main.php, which is something you cannot do with variables.
  14. Pretty sure that's just a typo, and should read "This does the same as above". You can do anything with Markup Regions that you can do with the typical delayed output approach. Each markup region serves the same purpose as some variable that you would put markup in and output in _main.php, like $sidebar or whatever. There are a few ways. Here is one... _main.php (just showing the main content part - of course there will be <head>, footer, etc in this file too) <region id="main-content"> <region id="top"> <div class="full-width-coloured-bg"> <div class="container-1400px"> <div>SOME STUFF IN A CONTAINER</div> </div> </div> </region> <div class="container-1400px"> <div class="row"> <div class="col-10"> LEFT SIDE </div> <div class="col-2"> SIDEBAR </div> </div> </div> </region> basic-page.php This file can be empty because _main.php is based on the markup needs of basic-page. But until this bug is fixed you might want to include some dummy region in basic-page.php or else the Markup Regions parser won't be triggered and <region> tags in _main.php will not be removed. home.php <region id="main-content"> <div class="container-1400px"> <div>SOME STUFF IN A CONTAINER</div> </div> </region> services-page.php <region id="top"> <div class="full-width-coloured-bg"> <div class="container-1400px"> FULL WIDTH STUFF </div> </div> <div class="container-1400px"> <div>SOME STUFF IN A CONTAINER</div> </div> </region>
  15. Just a heads up regarding a possible fix posted in the GitHub issue: https://github.com/processwire/processwire-issues/issues/411#issuecomment-340139239
  16. I whipped up a module for this:
  17. In response to a wishlist request... Field Save + Add New Adds a "Save + Add New" button when editing a field. Usage Install the Field Save + Add New module. When editing a field, click "Save + Add New" if you want to save the current field and start the process of adding a new field. Note: The button will not redirect you to "Add New" if you are performing some special action such as duplicating a field or adding a field to a template. https://github.com/Toutouwai/FieldSaveAdd/
  18. I agree with @abdus that field rendering is the solution. But if you're just wanting a tidier way of doing what you are already doing then you can rewrite it as: <?php foreach($foos as $foo): ?> <div class="foo"> <h1 class="foo__title"> <a href="<?= $foo->url ?>"><?= $foo->title ?></a> </h1> <?php if($page->headline): ?> <h2 class="page__headline"><?= $page->headline ?></h2> <?php endif; ?> </div> <?php endforeach; ?>
  19. @SamC, I don't entirely follow what you are saying, but here are a few things that might help. 1. You can remove elements in _main.php by using "pw-remove" in a template file. _main.php <div id="main"> FULL WIDTH OR SIDEBAR IN HERE </div> <div id="sidebar"> THE SIDEBAR </div> basic-page.php <!-- Remove #sidebar --> <div id="sidebar" pw-remove></div> 2. You can have as many nested ID'd or region elements in _main.php as you like, and then modify/replace any of them from your template. _main.php <region id="main"> <div class="container"> <div id="main"> FULL WIDTH OR SIDEBAR IN HERE </div> <div id="sidebar"> THE SIDEBAR </div> </div> </region> home.php <div id="sidebar"> <p>Just customise the sidebar.</p> </div> basic-page.php <region id="main"> <div class="container"> <p>Use a completely different #main on this template.</p> </div> </region> 3. The three blog posts about Markup Regions can be a bit confusing because the spec changed as the feature was developed and none of the posts cover the entire set of available keywords and syntax. Check out the comments in WireMarkupRegions.php for a more comprehensive spec. /** * Identify and populate markup regions in given HTML * * To use this, you must set `$config->useMarkupRegions = true;` in your /site/config.php file. * In the future it may be enabled by default for any templates with text/html content-type. * * This takes anything output before the opening `<!DOCTYPE` and connects it to the right places * within the `<html>` that comes after it. For instance, if there's a `<div id='content'>` in the * document, then a #content element output prior to the doctype will replace it during page render. * This enables one to use delayed output as if it’s direct output. It also makes every HTML element * in the output with an “id” attribute a region that can be populated from any template file. It’s * a good pairing with a `$config->appendTemplateFile` that contains the main markup and region * definitions, though can be used with or without it. * * Beyond replacement of elements, append, prepend, insert before, insert after, and remove are also * supported via “pw-” prefix attributes that you can add. The attributes do not appear in the final output * markup. When performing replacements or modifications to elements, PW will merge the attributes * so that attributes present in the final output are present, plus any that were added by the markup * regions. See the examples for more details. * * Examples * ======== * Below are some examples. Note that “main” is used as an example “id” attribute of an element that * appears in the main document markup, and the examples below focus on manipulating it. The examples * assume there is a `<div id=main>` in the _main.php file (appendTemplateFile), and the lines in the * examples would be output from a template file, which manipulates what would ultimately be output * when the page is rendered. * * In the examples, a “pw-id” or “data-pw-id” attribute may be used instead of an “id” attribute, when * or if preferred. In addition, any “pw-” attribute may be specified as a “data-pw-” attribute if you * prefer it. * ~~~~~~ * Replacing and removing elements * * <div id='main'>This replaces the #main div and merges any attributes</div> * <div pw-replace='main'>This does the same as above</div> * <div id='main' pw-replace>This does the same as above</div> * <div pw-remove='main'>This removes the #main div</div> * <div id='main' pw-remove>This removes the #main div (same as above)</div> * * Prepending and appending elements * * <div id='main' class='pw-prepend'><p>This prepends #main with this p tag</p></div> * <p pw-prepend='main'>This does the same as above</p> * <div id='main' pw-append><p>This appends #main with this p tag</p></div> * <p pw-append='main'>Removes the #main div</p> * * Modifying attributes on an existing element * * <div id='main' class='bar' pw-prepend><p>This prepends #main and adds "bar" class to main</p></div> * <div id='main' class='foo' pw-append><p>This appends #main and adds a "foo" class to #main</p></div> * <div id='main' title='hello' pw-append>Appends #main with this text + adds title attribute to #main</div> * <div id='main' class='-baz' pw-append>Appends #main with this text + removes class “baz” from #main</div> * * Inserting new elements * * <h2 pw-before='main'>This adds an h2 headline with this text before #main</h2> * <footer pw-after='main'><p>This adds a footer element with this text after #main</p></footer> * <div pw-append='main' class='foo'>This appends a div.foo to #main with this text</div> * <div pw-prepend='main' class='bar'>This prepends a div.bar to #main with this text</div> * * ~~~~~~
  20. Yes, the suggested fix in the GitHub issue is to replace the all the code in the "problem" block with the code in the "fix" block.
  21. That's an 11MB page you have there! And just wondering: how come the map is an image (2MB alone) instead of a real map?
  22. That's actually a different issue with a different cause. But I think I've found fixes for both issues. The new issue is here: https://github.com/processwire/processwire-issues/issues/419
  23. I tested with the core Checkbox fieldtype. You can check the fieldtype by opening the field (Setup > Fields > Your field) and looking in the Type dropdown. Not sure why it wouldn't work for you, but there is no real harm in just sticking with what you are doing (combining two PageArrays together) unless you have a huge number of children.
  24. You might find it easier to debug this and get it working by using a PW page to respond to your AJAX requests. So you create a template named "web-service" (for example) and put the code above into the template file (minus the bootstrapping line). Then create a page named "web-service" that uses this template and use this page's URL in your AJAX request. You might be able to get pagination working simply by enabling pagination for the template, or you might need to get the page number using the API and use it in conjunction with the "limit" to get the "start" for your selector. I haven't tried AJAX pagination myself.
×
×
  • Create New...