Leaderboard
Popular Content
Showing content with the highest reputation on 03/29/2016 in all areas
-
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, Andreas10 points
-
Something using WireArray and WireData. You could use it like this, and all WireArray method would be usable like find(selector) , filter(), remove(), sort() etc. Somewhere in an autoload module or in /site/init.php <?php class MySiteConfig extends WireArray{ public function addItem($key, $value){ $item = new WireData(); $item->name = $key; $item->value = $value; $this->add($item); return $this; } public function render($key){ $str = ""; foreach($this->find("name=$key") as $d) $str .= " " . $d->value; $str = trim($str); return $str; } } // create a new "global" $siteConfig template variable $myConfig = new MySiteConfig(); $this->wire("siteConfig", $myConfig); $siteConfig would then be available everywhere. The addItem() would allow to add items to the WireArray with name -> value. In basic-page.php Template file: $siteConfig->addItem("classes", "main")->addItem("classes", "myClassX"); $siteConfig->addItem("classes", "myClassY"); $content .= wireRenderFile("blog"); then in the blog.php partial $siteConfig->addItem("classes", "blog"); ?><div class='blog <?php echo $siteConfig->render("classes"); ?>'> <h1>Blog Test</h1> <?php // example of using WireArray's implode() echo $siteConfig->implode(" ", "value"); // example of filtering items $vars = $siteConfig->find("name=classes, value^=my"); if($vars->count) { foreach($vars as $v) echo " $v->value"; } ?> </div> This would be easy to extend with further helper methods etc. Also in your template site/init.php or templates/_init.php you could create various template variables That is just a fictive example, not sure how practical this is for handling a use case mentioned in this thread.5 points
-
I find it very easy to install PHP, URL Rewrite 2.0 and PHP manager with the help of Microsoft Web Platform Installer (WPI). Download and install WPI at http://www.microsoft.com/web/downloads/platform.aspx and then from the list of Products/Frameworks add PHP, from the list of Products/Tools add PHP Manager for IIS and from the list of Products/Server add URL Rewrite 2.0. Click "Install". Next download and install MySQL at https://dev.mysql.com/downloads/windows/installer/. You will need web.config, see attached zip. Run install.php and follow the instructions. webconfig.zip5 points
-
I would say because kixe is not the author so he can't just implement those features in the official release, but if needed before the author can implement or pull a request he can just fork to make his own version3 points
-
I recently found Concierge which supports both chat and video sharing capabilites. As of right now it's totally free! https://live.gotoassist.com/3 points
-
Thank you very much! Will testing soon....I'm testing PW dev with modules that i use and - TracyDebugger - is on my list, too!! I wish to get more deeper into the rabbit hole and i think tracy would help me to find a faster/better way. Padawan i am - learning i should3 points
-
Ok I've found the culprit. When an image has a caption, the .figure selector, for some reason, has a 1px width in contents.css of the CK Editor CSS figure { display: table; width: 1px; margin: 1em 0; } I'll check my other sites later. Just to clarify - this is in the Admin itself. It's not a style I applied although if it's not what you all have them I'm curious how it got there.3 points
-
Here are some Windows specific posts: https://processwire.com/talk/topic/268-processwire-on-windows72008-server-with-iis-webserver/ https://processwire.com/talk/topic/8933-windows-iis/ https://processwire.com/talk/topic/11530-windows-2008r2-iis-75/ https://processwire.com/talk/topic/3558-microsoft-iis-and-processwire/3 points
-
Sorry about that @mr-fan - looks like a forgot to change the name of a few variables when I did some refactoring a while back. This only affected CSV creation of pages. Please check the latest version and let me know if you still have any problems. I know I am OT and bordering on self promotion (actually it's promoting the Tracy guys), but the new AJAX functionality that just got added to TracyDebugger made debugging this so easy3 points
-
As the normal WireMail uses php's mail() to send mails you can see all possible settings at http://php.net/manual/en/function.mail.php So you in PW it should be $mail->header('Reply-To', 'webmaster@example.com'); Haven't tested it but should do what you want ;-)3 points
-
3 points
-
Are these names for real? Saying that the 'settings are OK ' isn't very helpful I am afraid . OK in what sense? OK for your ProcessWire install? Something else? There is nothing like WP or ProcessWire FTP . What I think the hosting provider was telling you is to activate your FTP account and, because many FTP programmes have features that allow you to change file permissions (maybe even ownership? not sure), to use such an FTP programme to change your file/folder permissions. Like @horst intimated, your problem is most likely one of ownership. Have a read here about file permissions and ownership. How did you install ProcessWire on that server? Are you able to install modules just fine?2 points
-
Perhaps temporary, one-time-only hashes? Apart from making it impossible to continuously re-use your resources on other sites this makes very little sense to me: in order to use those resources the browser needs to download them and at that point there's no reason to hide them, since the user already has them. In other words this would make your site eat an awful amount of resources for very little actual benefit and it would make caching almost impossible. On the other hand, if you really just want hashed URLs, and they don't need to be one-time, check out the AIOM+ module. It does some of what you've asked here out of the box, i.e. provides hash-style URLs for CSS and JavaScript resources. It does introduce some additional benefits speed-wise too, so it's not a bad idea to check it out either way.2 points
-
hanna code snippets are evaluated multiple times in the lifetime of a single pageview, which means the function declaration is called multiple times, which is not allowed. Try creating the function in _init.php or another file which is called only once on for each request and just execute the function in the hanna code snippet.2 points
-
I forked the module on github which allows the following paths for example: styles/style.css (relative to template - default) /site/folder/style.css (relative to root - NEW) https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js (absolute path to external source via http request -NEW) https://github.com/kixe/ProcessWire-AIOM-All-In-One-Minify2 points
-
Just tried it. Just enable directory traversal in AIOM's module config and then use this path $styles[] = '../../wire/templates-admin/styles/font-awesome/css/font-awesome.min.css';2 points
-
in my config.php, i setup an empty array for siteSettings like this: $config->siteSettings = array(); then in my ready.php file i'm array merging some values from a settings table (profields table), in the admin like this: $st = $pages->get('/settings/')->settings_table; $settings = array(); foreach($st as $row) { if(!$row->value) continue; if($row->disable == 1) continue; $settings[$row->setting] = $row->value; } $config->siteSettings = array_merge($config->siteSettings, $settings); i'm curious if anyone sees any possible issues with this; it works now and i can access my siteSettings everywhere doing this;1 point
-
Hi all, Just in front of the Easterweekend, my first contribution to the modules section of ProcessWire. I created a module to send Tweets when selected at the page editor. From version 0.8.3 up the module is only to use in v3.x. When using ProcessWire v2.x you should use version 0.8.2. In short this module offers an option to publish a page to Twitter when the date for publishing is past/scheduled. After filling out the Twitter credentials, select your preferable template(s) which should have the option added to Tweet the pages using it. Additional select the field to use as publicationdate to check if the Tweet should be send now or later, a field which contains the page title. Optional you can fill out the name of the website which will be added after the title (in case space is available). Optional you can select the field where the page image(s) are placed (only one will be tweeted). Optional you can fill out Bit.ly credentials for shortening URLs. Includes instructions to set a cron (template or LazyCron), returns log in assets folder. Uses (included) TwitterOAuth PHP library written by abraham. http://modules.processwire.com/modules/publish-to-twitter/ https://github.com/FerdiAgrio/PublishToTwitter Enjoy!1 point
-
Hi there, After using a number of image services that have very nicely taken care of responsive image handling for me, I have now put together code that will output image elements in a variety of ways dependent on their definition in the back-end of the PW system. So, things like Viewport width, DPR and Art Direction (Picture) based representations. In the past, I just loaded the largest, highest quality image to the image service provider and the client-side JS decided, based on runtime condition, what size and pixel density image version were required. I haven't used ProcessWire's image handling capabilities, other than just loading images into the "images" field which has provided the original path used by the responsive image services. Here is the nub of the gist. If I start with the same source image provided by the photographer, as referred to earlier, is there anything in ProcessWire that will either automatically or manually, help me to create the various versions of the images that I want to include in my image element's srcset attribute? Or, does this have to be done outside of ProcessWire, say, in Photoshop or Lightroom? I really appreciate your thoughts, ideas and comments around best practice in this regard, within the context of ProcessWire. Cheers!1 point
-
"the images are tremendously huge!! the first for example is 2248x3000 @ 1.9MB" With tinypng/tinyjpg it becomes 189.0 KB (−91%)... @bernhard: <img src="<?= $page->your_image->size(1000, 1000, array('cropping' => false))->url ?>" alt="..."> Does this code mean that the dimension closest to 1000 will have this value, and that the other dimension's new value will be proportional? Edit: the opposite had more sense.1 point
-
@Soma: Thank you for the detailed tip! I think it is more versatile than what we have came up with so far. As far as I can tell, your render method example covers the particular use case we dealt with in this thread and surely with even more helper methods added to the class all sorts of utilities can be implemented.1 point
-
1 point
-
If urls without trailing slash are not allowed in the template's settings then it will redirect to the url with slash swallowing the get parameters.1 point
-
1 point
-
And if the path is hashed, how should the browser find the CSS file? Can you please provide a link to a description of this feature from October CMS?1 point
-
1 point
-
I've just bookmarked this recently: https://rocket.chat/ "The Ultimate Open Source Web Chat Platform" "From group messages and video calls all the way to helpdesk killer features. Our goal is to become the number one cross-platform open source chat solution."1 point
-
True, but a hidden css file cannot power a public website because – well – it's hidden. That's why I asked for specifics.1 point
-
I'm also curious what october cms does (trys) to hide your css. Do you have any examples?1 point
-
// project $class2 = $page->category->has($child->id) ? " class='on2'" : '';1 point
-
Looks like the server overwrite your setting after wiremail sends it. You need to refer to your server settings and change them.1 point
-
You guys have to do it through Google translate. I'll give you something straight from the target audience of this update. ПроцессВаир теперь поддерживает кириллические урлы! С сегодняшнего дня сайты в зоне .рф можно полноценно создавать на этой замечательной системе. Благодарим Райана за заботу. Ура, товарищи!1 point
-
1 point
-
You can make your own array and pass it as an argument to the render() method. A short snippet exemple for your need : $website = ""; $options = array('headline' => '<h2>Einträge</h2>'); if (strlen($website)<=0) { $temp = array('commentHeader' => 'Geschrieben von {cite} am {created}'); } else { $temp = array('commentHeader' => 'Geschrieben von <a href="{website}">{cite}</a> am {created}'); } $options = array_merge($options, $temp); $temp = array( 'dateFormat' => 'd/m/Y', 'encoding' => 'UTF-8', 'admin' => false ); $options = array_merge($options, $temp); echo $page->guestbook->render($options); // argument as Array()1 point
-
Just thought I'd add the solution to this problem, for reference. Turns out there's a file called /site/assets/cache/LazyCron.lock (or something along those lines) preventing the cron functionality from working when there are PHP errors in my cron logic, which can happen during development of course. Fixing the errors and deleting the lock file restores functionality.1 point
-
very easy now with newer versions! just put this in your /site/ready.php $wire->addHookAfter("Session::login", function(HookEvent $event) { $user = $event->return; // check if login was successful if($user) { // your condition here if(!$user->isSuperuser()) { // your destination page here wire('session')->redirect('/'); } } });1 point
-
@Wanze I set up a quick and dirty test for jsPDF library here: http://jspdf.webseiten-fuer-alle.de/ Underneath "Choose example" select "**NEW: addHTML()" and you will see the result instantly It handles floating images and divs very well. I like the way you can just drop in a complete HTML page and the result seems to be almost exactly what you see in the browser. So no more extra pdf templates. Definitely looks promising. As for saving the pdfs, that's a good question. Browser support seems to be fine.1 point
-
1 point
-
So would this make sense then Soma? // $user is initially the user at time of page load // ... some code $users->setCurrentUser($u); $user = $users->getCurrentUser(); // ... carry on using $user as normal Unless maybe you could do $user = $users->setCurrentUser($u) but I don't know as I've not tested any of this - just thinking out loud.1 point
-
$user isn't updated since you're in a template and $user was set before you execute this code. $users->setCurrentUser($u); echo "<br />After setting current user: " . wire("user")->name So the new current user would only be available via wire("user") or $users->getCurrentUser(), that will get the new current user.1 point
-
I'm not sure I understand the example. What is NubUsers and NubPages? Also something like $fields->find("page=$r->id"); is completely unfamiliar to me. It seems like there are some parts ProcessWire and some parts something else? Here's a simple example that does exactly that: foreach($page->fields as $field) { echo "<p>"; echo "Field: {$field->name}<br />"; echo "Type: {$field->type}<br />"; echo "Value: " . $page->get($field->name); echo "</p>"; }1 point