Leaderboard
Popular Content
Showing content with the highest reputation on 09/27/2015 in all areas
-
Using Hashids you can accept encrypted page IDs in a querystring, decode them for use in selectors. Why would you want to do this? In my case I have a private calendar feed where each calendar is a page, but i don't want people seeing the page IDs and then possibly guessing another person's calendar id. 1.) include the hashids class, either with the composer or in my case i'm using the old version which is 1 php file (you can find this in the wordpress plugin version). 2.) Depending on which version you use, the method is different; read the docs to see which version you need; my code is relevant to the old 0.1.3 version which is good enough for this application. include('./classes/hashids.php'); $hashids = new hashids('your_unique_salt_here'); if($input->get->cal_id) { // the cal id coming in is a text hash ID: $cal_id = $sanitizer->text($input->get->cal_id); // decrypt the hash ID to the integer $cal_id = $hashids->decrypt($cal_id); // Look up the calendar: $calendar = $pages->get($cal_id[0]); if( !$calendar->id ) exit('Calendar not found.'); // at this point you would execute your actions, e.g. render your calendar feed etc.. exit(); } You would also need a way to generate your links wherever you are sending or displaying them, with the hashed ID. $calId = $hashids->encrypt($calendar->id);5 points
-
Hello everybody, I found about processwire when in search of a new CMS for my sites. Mainly there were articles in blogs that made me curious. I found it difficult at first ... wasn't used to the freedom the system gives me. Yes it's a freedom to have fields and templates for whatever you like. But coming from other cmses one is not used to having that freedom. In most cms you're told what to do where and how. Processwire is different. Also ... the many tutorials are very helpful, the API docs , the forum. Though I didn't need to ask questions here myself up to now I found answers for all the problems that arose while working. Putting it together: I feel comfortable here and hope to make some more sites with it.4 points
-
yep - in my case we also hash the client ID: $client_key = $calendar->client_select->id; $ak_hashed = $sanitizer->text($input->get->access_key); $access_key = $hashids->decrypt($ak_hashed); if($client_key != $access_key[0]) exit('Invalid Access Key'); As Teppo points out, using 2 hash IDs, one for the the page and one for the user and then seeing if the user has access to that page is an additional security. In my case these are not users, but simple pages storing contact info; You could also get real PW users and then use ACL to check for access...3 points
-
First of all, thanks for sharing this. Hash ID's have their benefits, and your method is a nice example of getting started the easy way A hashed ID is essentially password authentication, though without the need to type in a username. For use cases that require more security, one should consider not using this method alone, but, for an example, combining it with another GET param (which would be a username, constant API key, or something similar) and perhaps making the salt unique on a per-user / per-calendar basis. Additionally detecting multiple attempts for different ID's from one client and issuing a cooldown period (a ban) automatically would make sense, to prevent malicious attempts to gain access to calendars, which might contain very private data. Just my five cents3 points
-
It's not so much 'troubles', just something to be aware of. Incidentally Ryan has a quite nice write-up about pagination (and some other stuff) in this weeks blog post. https://processwire.com/blog/posts/processwire-2.6.18-updates-pagination-and-seo/2 points
-
Hi FreeAgent, the renderNav function only processes the items within the PageArray just in the order how you have created the PageArray. So, you don't need to change the renderNav function, you need to sort the items of the PageArray in the order you want them to be displayed. First thing is: how have you managed the order in the admin pagetree (in backend)? have you set the blog children to be sorted newest first? ("-created") If not, you I think you should set it this way and I expect that this order will be used to build the PageArray what is passed to the renderNav function. Changing the sort order for a pages children can be done by opening the relevant page for editing, selecting its children tab and go down to the field "sort settings". --- --- --- And going one step further: To ignore the selected sort order of the Admin-PageTree and to sort items of PageArrays by the API is also possible and used very often. // here you collect all children of the current page $pageArray = $page->children("sort=-created"); // here you first "get" the blog-page (the parent / rootparent of all blog entries) and then collect all of its children $pageArray = $pages->get("name=blog")->children("sort=modified"); // with the selector string you can, (besides others), also pass a param for the sorting order // "find" something different: $pageArray = $pages->find("template=news, sort=-modified"); // it is possible to sort by other things, please refer to the docs . Also useful is to refer to somas awesome cheatsheet.2 points
-
Hi, I'm not sure if this can be useful or not. Check by your self. I have created a little module around a set of 42 svg icons. (nearly a copy from Windows 10 iconset). It is very rudimentary at the moment. One can define settings for colors and size of the svg variations. Variations will be created on demand in a central directory (assets/svgicons/) and cached for later usage. The settings can be passed as selectorstrings. You can use a template variable $icon. To output markup for a plain svg icon in an image tag, you need to call the name: echo $icon->img("name=lock"); echo $icon->img("name=unlock"); If you want use it as a rollover with hover state, you need to call the function markup: echo $icon->markup("name=attention"); This gives you markup with default settings. If you need a clickable link, just define it in the selector string: echo $icon->markup("name=attention, link=/about/"); You can set / change the default values from template like: $icon->setColors(array(0, 111, 187, 0.2), array(219, 17, 116, 1.0)); $icon->setSize(180); and / or you can use individual settings for each icon: echo $icon->markup("name=document, size=32, color1=#775599, color2=blue, link=/about/"); // HEX colors or named colors echo $icon->markup("name=idea, size=120, color1=255-255-0-0.3, color2=255-255-0-1, link=/about/"); // RGBA colors echo $icon->markup("name=home, size=20, color1=230-0-0, color2=230-0-0, link=/about/"); // RGB colors . For the rollover / hover markup there is a piece of css needed what can be outputted (only once). It can be fetched with or without the style-tags: echo $icon->css(); // with style tags echo $icon->css(true); // suppress the style tags . The functions that does not output markup return the module itself (the $icon object). So you can use them chained: // all functions that can be chained: $icon->emptyCache()->setSize(100)->setColors(array(0, 111, 187, 0.25), array(243, 79, 159)); // after such a (re)set call, you only need to pass a name to each icon call to get consistent results: echo $icon->markup("name=lock, link=/logout/"); echo $icon->markup("name=unlock, link=/login/"); // you can override single settings, ->mu() is a shortcut for ->markup() echo $icon->mu("name=trash, size=200"); echo $icon->mu("name=key, color2=red"); // ->presentation() print the whole collection with optionally individually specified size and colors: echo $icon->presentation(100, array(0, 111, 187, 0.25), array(243, 79, 159)); . . . The code is here in a gist: https://gist.github.com/horst-n/f6922f6fa228991fd686 . Download it as ZIP! . . A live demo is here: http://images.pw.nogajski.de/svg-icons/ . .1 point
-
SOLVED: changed the module name from MarkupSVGIcons.module to MarkupSvgIcons.module - error is gone away.1 point
-
You can certainly achieve such a site with processwire and as it's essentially just a single type of content you need to manage (videos with outsources comments / likes) it shouldn't be to hard to create. SEO can be done in ProcessWire and there's also a module for it. But you've to determine for yourself if it fits your needs. You can always fall back to implementing own seo generation functionality. The account management won't be of any issue as long as you manage users in the backend. If you need to create custom interfaces for them in the frontend (adding videos or editing their user settings) it's certainly more work to do with all the validation and security implications you need to be aware of.1 point
-
1 point
-
It's been an extremely busy last few months for me, but I finally managed to launch Christopher Todd Studios: http://christophertoddstudios.com/ I'm using my go-to frontend approach, which is based off of Sage. Some frontend packages I'm using include: Bootstrap SASS Animsition for the page transitions Slider Revolution for the home page slideshow (using the Ken Burns effect) Slick Carousel for the portfolio slideshows (with the lazy loading feature enabled... very important) Ekko Lightbox for the video modals Headroom.js for the navbar hide/show interaction jQuery Lazyload for other image lazy loading (like the blog) MatchHeight for some areas that need matched heights ResponseJS for loading content when a specific breakpoint is hit (rather than it being loaded but hidden, which is bad for performance and sloppy; very important) Linearicons I wrote the slideout navigation menu myself. Just some CSS and JS. My goal was to make sure this site is fast and doesn't feel clunky. I feel it has met that objective especially with the performance and optimizations that have been done (there's still a few I will eventually get to and squeeze out even more performance). In terms of ProcessWire modules being used: FormBuilder is being used and it's submitting results to Tave, which is a lead management system. FormBuilder made this easy with its 'Send duplicate copies to to another URL or 3rd Party Service' feature. Image Extra Social Share Buttons Page List Image Label Hannacode The original site was based on WordPress and had many blog articles. Using Ryan's great writeup, I imported all the posts into ProcessWire. The blog setup is self made and inspired by the Blog Profile (not using the blog module). The original site also didn't have permalinks enabled in WordPress, so I wrote some code to capture the necessary URL variables and forward them to the correct page so that old links are maintained, which is also good for maintaining SEO. The client loves ProcessWire and its simplicity.1 point
-
vagrant (+ virtualbox) + git is pretty encapsulated vagrant streamlines the process of generating virtual machines to develop on, by providing 'prepackaged' virtual images + options to include other provisioning software (like puppet, chef, etc.). Some use Vagrant VMs as 'apps', meaning that each project has its own virtual machine, some other people have one VM for multiple sites (a la *AMP software). In your case, you could have your site versioned in git, together with your mysql dump and Vagrantfile (vagrant 'recipe' for your vm), and when you come to new machine, you'd do something like 'git clone project && cd project && vagrant up', go have a coffee, come back and start working. (of course, it's never quite that simple IRL , but in gist vagrant is quite nice. I am in the process of setting up local vagrant from clean ubuntu + serverpilot.io over vpn. fun times)1 point
-
You're using limit in both selectors and pagination does set the start value automatically, if there's non present. That's why both finds do get paginated. Add start=0 to the widget selector and it works.1 point
-
Welcome to the forum Hanna, thanks for your insight. Hope to see you around here from now on1 point
-
Another idea - what about storing the icon code in the db? You could maybe even have a module config tool for adding new icons - an upload field that takes the SVG from the uploaded file, and encodes it so it's ready for storage and usage in the module? Or maybe write the encoded content back to the file in the filesystem?1 point
-
Looks awesome horst! What do you think about maybe defining the icons in a different file? Either for all the icons, or an optional, additional file that each developer can maintain for their own icons? I actually think two separate files might be nice - one in your module's directory so that we can easily contribute new icons via PRs, and the another one that sits under /assets/svg-icons/ that we can maintain ourselves.1 point
-
If field can contain only one value or a string... if($page->title) echo $page->title; If field can contain multiple values, e.g. a multiple image field or multiple page field (i.e. contain arrays) if(count($page->images)) echo "we have images. Let's foreach them"; https://processwire.com/talk/topic/2239-how-to-test-for-empty-fields/ https://processwire.com/talk/topic/546-how-to-detect-an-empty-field/ https://processwire.com/talk/topic/8067-cant-detect-empty-field/ https://processwire.com/talk/topic/957-how-to-find-elements-with-empty-field/ https://processwire.com/talk/topic/8850-check-if-a-datetime-field-is-empty-does-not-work/ https://processwire.com/talk/topic/4177-checking-for-empty-textarea-field/ https://processwire.com/talk/topic/3050-checking-for-a-field-if-else/ etc....1 point
-
Hi pitbull Download the fullcalendar from the link below http://arshaw.com/fullcalendar/download/ Upload the fullcalendar.css , fullcalendar.print.css and fullcalendar.js to your server end embedded in your page header like this <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates ?>assets/css/styleaahaeota.css"> <link href='<?php echo $config->urls->templates ?>assets/calendar/fullcalendar.css' rel='stylesheet' /> <link href='<?php echo $config->urls->templates ?>assets/calendar/fullcalendar.print.css' rel='stylesheet' media='print' /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="<?php echo $config->urls->templates ?>assets/js/bootstrap.js"></script> <script src='<?php echo $config->urls->templates ?>assets/calendar/fullcalendar.js'></script> add the code below in your header after the <script src='<?php echo $config->urls->templates ?>assets/calendar/fullcalendar.js'></script> <script> $(document).ready(function() { $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, editable: false, events: "http://weborange.gr/aahaeota/json-events.php", eventRender: function(event, element, view ) { var image = '<img src="'+event.img+'" />'; if (view.name === "agendaDay") { element.find('.fc-event-title').append("<br/>" + event.description); } // on event hover pop up a small discription of the event and an image, // i use bootsrap framework so popoever is curently works only for // bootsrap details in http://twitter.github.io/bootstrap/javascript.html#popovers //if you dont want this, delete it or take the code from my last post element.popover({ html: true, trigger: 'hover', title: event.title, placement: 'top', content: image + '<span class="calendar-detail-time"> ' + event.ddate + ' until ' + event.dend + '</span>' + '<br/>' + event.description , }); }, eventDrop: function(event, delta) { alert(event.title + ' was moved ' + delta + ' days\n' + '(should probably update your database)'); }, loading: function(bool) { if (bool) $('#loading').show(); else $('#loading').hide(); } }); $oldTable.remove(); }); </script> create a new php file called json-events.php and upload it in your root folder. Inside json-events.php add the below code <?php include("index.php"); // bootstrap ProcessWire function pagesToJSON(PageArray $events) { $json = array(); foreach($events as $event) { $json[] = pageToArray($event); } return json_encode($json); } function pageToArray(Page $event) { $data = array( 'id' => $event->id, 'title' => $event->title, 'start' => date("Y-m-d H:i",$event->date_start), 'end' => date("Y-m-d H:i",$event->date_end), 'url' => "$event->url", // event ID is the url segment 'description' => "$event->summary", //event summary for bootsrap popover 'allDay' => false, 'img' => $event->images->first()->url, //event image for bootsrap popover 'ddate' => date("d-m-Y H:i",$event->date_start), //event date start for bootsrap popover 'dend' => date("d-m-Y H:i",$event->date_end), //event date for bootsrap popover ); return $data; } // end else $eventPage = $wire->pages->get('/events/')->children(); echo pagesToJSON($eventPage); ?> and final in the template that you want to render the calendar add <div class="tab-pane" id="calendary"> <div id='loading' style='display:none'>loading...</div> <div id='calendar' class='calendar-page'></div> </div> that's it, you can see example here just go one month before from the upper left arrows sorry for my bad english , i hope that this is going to help you1 point