Jump to content

AndZyk

Members
  • Posts

    678
  • Joined

  • Days Won

    10

Everything posted by AndZyk

  1. Actually I don't need the ProcessWire namespace at all in my template files. I just thought it would be good to add it manually to avoid that my template files would get compiled unnecessary. But since that doesn't work, I think I will remove the namespace again and set the file compiler for my templates to "Auto", as recommended.
  2. Honestly, I never worked with namespaces in PHP before. I just read in one of Ryan's blog posts, that you can add it to skip the file compiler. So should I remove the namespace of my template files?
  3. Hello, I am a little bit confused about the new file compiler template options. I have a clean ProcessWire 3.0.15 dvns installation and the basic-page template. Now If I add the ProcessWire namespace to my template file <?php namespace ProcessWire; and set the file compiler for this template to "Auto" (default), it still compiles the template to site/assets/cache/FileCompiler/site/templates/basic-page.php. Only if I set the file compiler to "No", of course, it doesn't compile. Shouldn't the "Auto" option detect if I had added the namespace manually and skip compiling the template? Also I noticed that, when I don't have the namespace added in my template file, the compiled files don't have the namespace added as well. Regardless of wich option (besides "No" of course). Am I misunderstanding something and the namespace is added somewhere else or is this maybe a bug?
  4. Just my opinion, but I wouldn't recommend Twig. I realized three projects with it and first it is all fun, how simple the syntax is for outputting something. But every time I wanted to build something a little more complex (for example a contact form or search function), I first had to learn how to build it in PHP and after that try to recreate it in Twig. I always had the impression, that the api of twig is somehow limited, but maybe I haven't looked close enough at the documentation.
  5. Alright. If I notice something is missing, I will post it here.
  6. With Version 2.5.0 they changed the class names of the HTML form to "typeahead__". I updated it in my original post, just so nobody gets confused.
  7. I'm happy you find this tutorial useful. But since this topic is specific for the front-end and uses one of many plugins, I don't think this should be covered in the documentation. Because after all, ProcessWire doesn't dictate you how you should do things in the front-end.
  8. Is there a way to contribute to the documentation or cheatsheet? I know, that the heavy users probably will now use kongondos apigen documentation or look at the core files themselves. But I think most users will first look at the documentation or cheatsheet. Often when I go through Ryans older blog posts, I find nice methods, that are nowhere else documented. Here are two examples: New $pageimage->maxSize($width, $height) method What's new in the core this week? New API syntax options! Those two examples can't be found neither in the documentation nor the cheatsheet. Also they can't be found through the site search and are hard to find through the Google Search. I wouldn't consider myself being capable writing the documentation, but I would like to post when I find something is missing. Should I do this in this forum or is there a form/mail address I can contact?
  9. @bernhard You could also use the maxSize method: $thumb = $image->maxSize($width, $height); This method does also resizing without cropping. Too bad this nice method is only documented in the blog post and cannot be found through the site search. Hopefully the documentation will be updated with the stable release of ProcessWire 3.
  10. Hello everyone, I always wanted to try out an ajax autocomplete search function, but never knew where to start. Of course there is the Ajax Page Search module by soma, but it seems that it was build around the basic site profile. In my case I wanted something more custom and I discovered in this thread the jQuery Plugin Typeahead by RunningCoder, which seemed to be nice. After many hours figuring out, how to combine this Plugin with ProcessWire, I finally got it implemented and want to share my solution with anyone, who also struggles with this topic. 1. Set-Up Typeahead Download the Typeahead-Plugin from the website (I prefer via Bower) and include the following scripts and stylesheets in your templates: <html> <head> ... <!-- Optional CSS --> <link rel="stylesheet" href="/vendor/jquery-typeahead/dist/jquery.typeahead.min.css"> <!-- Required JavaScript --> <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> <script src="/vendor/jquery-typeahead/dist/jquery.typeahead.min.js"></script> ... </head> As next step we need the JSON data. 2. Install Pages to JSON To get the necessary data of all pages as JSON, I use the module Pages to JSON, which provides an easy way to output pages as JSON objects. Of course you can achieve this without this module, but I am not very experienced with JSON, so this module was really helpful. After you downloaded and installed the module, you can configure in the module settings page, which fields you want to output. You can select between own and system fields. For my purpose I selected only title and url to be outputted. 3. Output JSON Now, that we have the module configured, we have to output our search suggestions as JSON. I did it in my template file search.php like this: <?php namespace ProcessWire; // Check if ajax request if($config->ajax) { $results = $pages->find("has_parent!=2"); // Find all published pages and save as $results header("Content-type: application/json"); // Set header to JSON echo $results->toJSON(); // Output the results as JSON via the toJSON function } else { // Your own front-end template } To sum up, we search the pages we want as search suggestions and save them in a variable. Then we output them with the toJSON-Function by the Pages to JSON-Module. All of this happens in a Ajax-Request, that is the reason why we check first, if the page is called via an Ajax request. 4. Insert Form We can now embed the HTML form anywhere you want. Either in an header-include or a specific template. Also you can use your own classes, for this example I used the Typeahead-demo-mark-up and extended it a little. <form id="searchform" method="get" action="<?= $pages->get("template=search")->url ?>"> <div class="typeahead__container"> <div class="typeahead__field"> <span class="typeahead__query"> <input id="q" name="q" type="search" placeholder="Search" autocomplete="off"> </span> <span class="typeahead__button"> <button type="submit"> <span class="typeahead__search-icon"></span> </button> </span> </div> </div> </form> The action-attribute in the form-tag is the url of your search-site. This attribute is of course necessary to know where the form redirects you and where the JSON data is located. 5. Initialize Typeahead As last step we have to initialize the Typeahead-plugin jQuery like this: $(document).ready(function() { var actionURL = $('#searchform').attr('action'); // Save form action url in variable $.typeahead({ input: '#q', hint: true, display: ["title"], // Search objects by the title-key source: { url: actionURL // Ajax request to get JSON from the action url }, callback: { // Redirect to url after clicking or pressing enter onClickAfter: function (node, a, item, event) { window.location.href = item.url; // Set window location to site url } } }); }); We save the action url of the form in a variable, then we initialize Typeahead by selecting the input-field inside the form. As the source we can pass the action url and I included the callback, to link the search results with the site urls. Now you should have a nice ajax autocomplete search form, which of course you can further style and configure. I hope I didn't forget anything, but if so, please let me know. Regards, Andreas
  11. Hello Ivan, there is no long-click action on the save button. Only on the edit and view buttons in the page lister, as you already know. I think you mixed it up, with the long-hover over the save button to get more options.
  12. You are absolutely right, kongondo. My question was meant as a test to figure out, if the lcmini.php script is blocked by the .htaccess file. But your solutions are more secure.
  13. Hello dowmedia, have you enabled access to php files other than template files in your .htaccess? You can simply enable this by commenting this line in the .htaccess out: # Block access to any PHP or markup files in /site/templates/ RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ [OR] This line could block the lcmini.php script.
  14. If you don't want to use the template compiler, all you need to do is to add the ProcessWire namespace on top of your template file: <?php namespace ProcessWire; Here you can find the blog post about this topic.
  15. I am usually more the silent observer type of this forum, but I just want to say that Repeater Matrix, beside all the nice frequent additions, is by far my favorite addition to ProcessWire this year and really improves the workflow with custom content elements. I am really looking forward for more additions to this FieldType and thank you for coming up with it. Regards, Andreas
  16. AndZyk

    ServiceWorker

    Thank you for the quick answer. I'm glad to hear that it is possible to combine ServiceWorker with ProcessWire. I never tried it, but wasn't sure. I will test it out for myself some time, because I think this spec could improve your website a lot.
  17. AndZyk

    ServiceWorker

    After I discovered the SerivceWorker spec, which was demonstrated really funny and informative in this panel, I wonder if it is possible to combine it with ProcessWire? Is it possible to make offline websites with ServiceWorker and ProcessWire combined? Because you still would need a server to serve the PHP files or does it only work with static HTML files? This question is maybe silly, but I would like know if anybody has experience with this new spec so far. Regards, Andreas
  18. My suggestion does the same as Tom's, but I forgot, that you would like to echo the HTML code. Personally, I don't like to echo every bit of HTML, but as you said, it is a matter of preference.
  19. Hello Roderick, are you searching for this solution? <?php foreach($page->children as $child): ?> <div class="my-class"> <?php foreach($child->images as $image): echo "<img src='$image->url'/>"; endforeach; ?> </div> <?php endforeach; ?> Regards, Andreas
  20. Maybe the path to the ".htpasswd"-file is not correct. You can use this PHP-function to see the correct path: echo getcwd(); Beside that you could use a "robots.txt"-file for preventing search engines to crawl your site. A subdomain would also help I think as well as hiding the root page in ProcessWire.
  21. Great module with much potential. I also would like to have a more simple way to set the event recurrence.
  22. Nice site. For the images you could install an module for generating different versions of the image and use Picturefill to display them, because responsive images aren't supported by all browsers. No need for multiple image uploads.
  23. Maybe they wan't to be sure, that those icons will have transparency or maybe they plan to use those icons for something other than just pinning tabs. But right now you're right. Apple often wants some special treatment.
  24. Hey, I know this is not a request for ProcessWire itself and you probably got better things to do, but since the release of Safari 9.0 I started to like the new pinned tabs feature. As I am interested in all new things related to ProcessWire, I always got an tab open for your site as my starting point for new interesting topics. One thing I would like, is when I pin your site to see a neat little icon. So could you please implement that? It would only just take a couple of minutes. Regards, Andreas
×
×
  • Create New...