Jump to content

AndZyk

Members
  • Posts

    722
  • Joined

  • Days Won

    10

Everything posted by AndZyk

  1. 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?
  2. @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.
  3. 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
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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
  9. 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.
  10. 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
  11. 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.
  12. 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
  13. 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.
  14. Great module with much potential. I also would like to have a more simple way to set the event recurrence.
  15. 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.
  16. 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.
  17. 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
  18. I had the experience, that on one server I needed to set all permissions in the "site/assets/file"-folder to 777 in order to keep my ProcessWire install running. Although I highly wound't recommend it, because you would make your site vulnerable. A good server set-up wouldn't need such workarounds. But I am no expert in permissions as well.
  19. Welcome codevark, uncommenting line 124 in the .htaccess-File, for setting the RewriteBase to "/", as stated in the thread you posted didn't solve the problem? Usually this is the problem when a new ProcessWire install is hosted in a subdirectory. Regards, Andreas
  20. I think it is safe to say, that this thread was a simple way to seek attention and can be deleted.
  21. Welcome Claudio, may I ask, why you post a WordPress-website with an bought theme in this board? Besides that, I wish you good luck with your company. Greetings, Andreas
  22. Thank you, I didn't knew about this module. I just tried it out and it seems to work fine with my rendered output from the PageTable-Field.
  23. Exactly, that is what I wrote on my first post.
  24. My loop looks like this: <?php foreach($child->content as $element) { echo $element->render(); } ?> I don't quite understand your code, because you are not using the page object. Could you please explain why? I have never seen such variables in the context of ProcessWire. But I don't think that has anything to do with the module, so let's just wait, if the authors respond.
  25. May I ask, how do you output your content? Because if you simply echo the content it works as expected, but if you render the content the e-mail-adresses don't get de-obfuscated.
×
×
  • Create New...