Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/11/2016 in all areas

  1. In /site/init.php... $config->css_files = new \ProcessWire\FilenameArray(); $config->js_files = new \ProcessWire\FilenameArray(); In your Hanna Code PHP... $config->css_files->add('/site/templates/path/to/file.css'); $config->js_files->add('/site/templates/path/to/file.js'); Wherever you output your <head>... foreach($config->css_files as $css_file) { echo "<link rel='stylesheet' href='$css_file'>"; } foreach($config->js_files as $js_file) { echo "<script src='$js_file'></script>"; } See the code for the FilenameArray methods available: prepend(), remove(), removeAll(), etc. P.S. you can use the existing core $config->styles and $config->scripts FilenameArrays but other files might be added to these by certain modules so cleaner to create your own FilenameArrays I think.
    5 points
  2. From v043 that is just uploaded you have the option to disable the inline sidebar items. This feature is now available for all sidebar modes unlike before. For the modalModuleEdit tweak there are two additions: a secondary "X Submit" button for submit+exit, and ESC also closes the modal dialog.
    4 points
  3. ProcessWire by default blocks access to files with the extensions php, htm, html, inc and tpl underneath the templates directory (or, to be precise, the shipped .htaccess file does so). This is a security feature. Thus, to access third party PHP code, you have two choices: Move the relevant code outside of the templates directory or create a template with a PHP file in site/templates that includes the external library (in your case instapast-ajax.php, and that's where Ryan's quote comes in) and a page that uses this template (and that provides you with the URL to call from JS)
    4 points
  4. There are basically four different environments to talk about. TemplateFile TemplateFile is core class, which does include your template files, but does also power things like $page->render(), wireRenderFile(), wireIncludeFile() and others. This class will automatically make all API Variables available as local variables. Meaning all those included files can directly use $pages, $page, … . It won't work inside any functions defined in those files, because of the way PHP does scope variables. Classes extending Wire Every class, which is extending the Wire class will have access to API variables via $this->pages, $this->page, if the properties or __get() are not overwritten. Also there's $this->wire('pages'), which is less likely to be overwritten (even some core classes need to use $this->wire()). Anonymous functions There are some methods in the processwire code, which accept anonymous functions as parameters (e.g. WireCache). Those anonymous functions can retrieve api variables as parameters, even though I'm not sure how exactly this is working or if that's often used. Everywhere else Outside of wire classes, template files and special anonymous functions there's the wire() function, which is basically the same as $this->wire() in wire classes, but as a global function, which is accessable anywhere after pw is started. With PW 3.0 and multi-instance this is the option to avoid. Places, which technically are number 2, but it may not be apparent to everybody: Custom PHP code for fields like FieldtypePage or FieldtypeMarkup: As those PHP code is evaluated/run inside those (input)field classes there's (besides manually available local api variables) always the option to use $this->pages or $this->wire('pages'). All those template files included by the TemplateFile class: For the same reason as above there's not only $pages available in those template files, but also $this->pages, $this->wire('pages').
    3 points
  5. For anyone interested, there will be a (german) introduction hangout today about what that slack channel / community is all about and a little bit of craft talk (even though pw is also quite well represented).
    2 points
  6. I don't think there was a question, but it's rather a mini-tutorial.
    2 points
  7. I have tried the second choice of BitPoet too: Somewhere on a page I have two pieces of HTML: <!-- trigger --> <a title=“some title” class="instapast" data-insta=“some_page_id”>linkname</a> <!-- Zurb Foundation Reveal Popup --> <div class="reveal" id="instapastPopup" data-reveal> <h1 id="instapastPopupTitle"></h1> <p id="instapastPopupContent"></p> <button class="close-button" data-close aria-label="Close modal" type="button"> <span aria-hidden="true">&times;</span> </button> </div> The Javascript /templates/scripts/app.js jQuery(document).ready(function($){ var request; $('a.instapast').click(function(){ var id = this.dataset.insta; request = $.ajax({ url: "instapast-ajax/?id=" + id, // instapast-ajax.php is in the directory templates type: "post" }); request.done(function (data, textStatus, jqXHR){ var json = $.parseJSON(data); $('#instapastPopupTitle').html(json.title); $('#instapastPopupContent').html(json.text); $('#instapastPopup').foundation('open'); }); }); }); In Processwire I have made a Template: instapast-ajax And a page with the same name and the template avove: instapast-ajax That gives me the URL for app.js: /instapast-ajax/ The code in instapast-ajax.php: <?php namespace ProcessWire; //$ID = $_GET['id']; // not secure $ID = $sanitizer->int($input->get->id); // updated thanks to bernhard $instagramPickTitle_ = $pages->get($ID)->title; $instagramPickContent_ = $pages->get($ID)->text; $arr = array( 'title' => $instagramPickTitle_, 'text' => $instagramPickContent_ ); $json = json_encode($arr); echo $json; ps: I hope I did not forget something.
    2 points
  8. status=unpublished or include=unpublished
    1 point
  9. Yes! Thanks @LostKobrakai, thats it - should've tried that one too ... @Martijn Geerts, yep - I also tried wire('config') but that didn't work either – and I was not sure about `template=` vs. `template.id=`, too ... both work though PS: Is there actually some kind of summarized documentation of where which variables are scoped and why? Like to get to know some underlying concepts of processwire? Or a forums thread where things like that are explained more thoroughly?
    1 point
  10. The custom php code is executes as part of InputfieldPage and therefore all api variables are accessable as $this->… . Only $pages as $page are available as local variables.
    1 point
  11. I think that context can't access the $config variable. You could try wire('config')... What else: I'm not fully 100% sure that "template="..." would work you could also try "template.id="...".
    1 point
  12. Hi I also stumbled across this problem. It looks like the new variable handling of php7 is responsible for that... I found a solution wich works on php 5.6 and 7. Just posted an github issue with explanation... https://github.com/adrianbj/TableCsvImportExport/issues/1 greetings, tom
    1 point
  13. Exactly. There is no question anymore. It works. Just wanted to share.
    1 point
  14. what is your question? does it work or does it not work? don't forget to sanitize your input variables! $ID = $_GET['id']; // better $ID = $sanitizer->int($input->get->id); maybe also check if the page exists: if(!$pages->get($ID)->id) // return or throw error see https://processwire.com/api/variables/sanitizer/
    1 point
  15. I am trying to get a simple button working on Safari/601.1 (iPhone 6) without success, someone got it working on mobile device ? <button id='validate' ic-post-to='{$config->urls->httpRoot}contact_form.php' ic-target='#contact-wrapper' ic-indicator='#indicator'>SEND <i id='indicator' class='fa fa-spinner fa-spin' style='display:none'></i></button> edit: by visiting the official examples on their website, it works edit2: Something weird - it works if I hardcode the url of ic-post-to instead of using $config->urls->httpRoot
    1 point
  16. You could try my module MarkupGoogleRecaptcha or implement an honeypot field like in the SimpleContactForm module.
    1 point
  17. I split it up into two modules. TemplateFileHelper Inspired by Template Engine Factory and Wire Render Pattern. A simple module which hooks Page::Render and adds a global controller / template around the current loaded page if it isn't an admin page or an ajax call. It also takes care about css / js (files, "inline" and "$config->js()") and adds the method "load" to the TemplateFile class (which loads an template with an additional controller file). IntercoolerJS Depends on TemplateFileHelper (page template is current page only, global layout, it defines how to use / handle PW template files to be compatible to my IntercoolerJS module) and loads jQuery and intercoolerjs. I try to implement async js / css load (current page scripts and styles added inside a DIV and moved by JS code). I try to get it work with FormHelper module, but don't know if it would work with the PW inputfields.
    1 point
  18. You could try out my rest api helper https://github.com/NinjasCL/pw-rest Alamo Fire as AFNetworking its format agnostic, so it could easily adapt to your api design I recommend you to follow http://jsonapi.org principles. also reading this book https://leanpub.com/build-apis-you-wont-hate and this book https://leanpub.com/iosappswithrest could help you start out. If you need something done quick maybe using Parse Server SDK its more appropriate for a middleware (you can call PW later with that) https://parseplatform.github.io
    1 point
  19. selector_field is to define what field or property (runtime) you want to use to specify the selector. Default is "nav_selector" so this would translate to: $page->nav_selector = "yourselector" a) This can be a field on a page, create a text field named "nav_selector" and add it to you template. Now you can enter a selector on pages using this template and the module will take that if it's defined. b) Or you set it on the fly before you render the navigation. Then you don't need to have a text field "nav_selector" added to your templates at all. You just set the property with code. This could be simply a little code you run to set the selector to those pages, in your case those that have the checkbox: foreach($pages->find("dont_show=1") as $p) $p->nav_selector = "yourselector"; In your case I'm not sure what would be the best way to not render children of that page. Maybe something like this: foreach($pages->find("dont_show=1") as $p) $p->nav_selector = "parent!=$p->id"; c) Alternatively this could also work using the options "selector". "selector" => "parent.dont_show=0"; but not sure really this is possible at all
    1 point
×
×
  • Create New...