Leaderboard
Popular Content
Showing content with the highest reputation on 12/04/2015 in all areas
-
I just rolled it out on my photography portfolio, as the hoster is super active in tech. stuff and has already automated most of the hard work of setup. Went nearly to well. 3 ssh commands and some "I Agree" statements and I'd my site encrypted in about 10 minutes.7 points
-
echo use __toString() function and will return a string like '1'. In your case use API like: $image->issue_raw_image_width // returns (string) '1' $image->issue_raw_image_width->id; // returns (int) 1 $image->issue_raw_image_width->title; // returns 'Full' $image->issue_raw_image_width->value; // returns '' // settings: 1=Full|myvalue $image->issue_raw_image_width->value; // returns 'myvalue' Have a deeper look here: https://processwire.com/api/modules/select-options-fieldtype/#separate-option-values3 points
-
I updated module, on my side i don't have this issue anymore ! Updated many things and changed methods for loading icon list etc.. Next step is use other font icons !3 points
-
You may use one of those ready to use JS Libraries for Infinite Scrolling you can found on the net. One that I know and have used myself is IAS. In PW you must use pagination as you explained above, also have to render the NEXT button, but with display:none in CSS to make it invisible. The JS-Script will pick it up and loads the next portion when the user scrolls down.2 points
-
Thanks! @kongondo I already stumbled over this thread and your helpful post. In my case I couldn't disable the HTML Purifier, because it is mandatory with inline editor fields. But I'm happy with the Hanna Code workaround so far. P.s. For everyone, who also wants to embed responsive videos manually. You can use the html and style like the video embed module does: <div class="VideoEmbed" style="position:relative;padding:30px 0 56.25% 0;height:0;overflow:hidden;"> <iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" width="640" height="360" src="https://www.youtube.com/embed/yourvideoidhere" frameborder="0" allowfullscreen=""></iframe> </div>2 points
-
Different set of tools here (but based on somas great wordlimiter! I don't use it in a module via hook just in my _func.php and i use it on several different strings to get clean values for example a sumary of the body text if no meta description is set...and so on. regards mr-fan /** * Wordlimiter cuts a textarea only after complete words not between * used seo function and in some templates */ function wordLimiter($str = '', $limit = 120, $endstr = '...'){ if($str == '') return ''; if(strlen($str) <= $limit) return $str; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } $out .= $endstr; return $out; } /** * Alternative with regex for striptags function * used for seo function and in some templates */ function ripTags($string) { // ----- remove HTML TAGs ----- $string = preg_replace ('/<[^>]*>/', ' ', $string); // ----- remove control characters ----- $string = str_replace("\r", '', $string); // --- replace with empty space $string = str_replace("\n", ' ', $string); // --- replace with space $string = str_replace("\t", ' ', $string); // --- replace with space // ----- remove multiple spaces ----- $string = trim(preg_replace('/ {2,}/', ' ', $string)); return $string; }2 points
-
I needed to calculate recurrent dates for a project and at that time discovered that there is a PHP DatePeriod class for such type of calculations. It was not so easy for me to get my head around this but I finally came up with a function that is calculating recurrences from start date, end date and an interval. Not the same as your scenario, but maybe it can help to get you started. // DatePeriod calculation taken from http://php.net/manual/de/class.dateperiod.php#109846 function getRecurrences($startTime,$endTime,$interval) { $format = 'Y-m-d H:i'; $start = new DateTime(); $end = new DateTime(); $start->setTimestamp($startTime); // if interval 0 we calculate weekdays and set start = end; $end = ($interval == 0) ? $end->setTimestamp($startTime) : $end->setTimestamp($endTime); // if start and end time are the same, we calculate for weekdays and set endtime to 3 month from starttime $end = ($start == $end) ? $end->modify('+90 days') : $end->modify( '+1 minute' ); // set duration to move on in 1 day steps, if we are calculating timestamps for weekdays $duration = ($interval != 0) ? 'PT' . $interval . 'M' : "P1D"; $interval = new DateInterval($duration); $daterange = new DatePeriod($start, $interval ,$end); return $daterange; } EDIT: After reading carefully through your post again, I am wondering about your interval. You say you let the user define an interval as timestamp. But a timestamp typically is one point in time. So I am wondering how your timestamp looks like for describing a time range? Can you give an example? If you are using something like "+1 day", "+1 week" as an interval, you could use strtotime for your calculations, like $new_timestamp = strtotime('+1 week', time()); // + 1 week from today2 points
-
I discovered this by chance and wondered why it never got answered. So here it goes: PageTable field is just holding a PageArray. You'd then use $a->remove($key) where $key can be the key or a page object. Then save the page. // remove page $item from PageTable $page->pagetablefield->remove($item); $page->save();2 points
-
Sidenote In my experience simply truncating text to a hard limit to make summaries or intro text,rarely gives good results. If possible i would always choose for a designated summary/intro field. This just gives you more control and options and will probably save some headaches in the long run.2 points
-
You can, but it need some additional scripting. The below could be inside the init() of an autoload module. That would hide the pages you wish for the role my-role. Ps, the code here is not tested. $this->addHookAfter('Page::viewable', function($event) { if (!$this->user->hasRole('my-role')) return; $exclude_ids = array( 1234, 2345, 2323, ); if (in_array($event->object->id, $exclude_ids)) { $event->return = false; } });2 points
-
FieldtypeRuntimeMarkup and InputfieldRuntimeMarkup Modules Directory: http://modules.processwire.com/modules/fieldtype-runtime-markup/ GitHub: https://github.com/kongondo/FieldtypeRuntimeMarkup As of 11 May 2019 ProcessWire versions earlier than 3.x are not supported This module allows for custom markup to be dynamically (PHP) generated and output within a page's edit screen (in Admin). The value for the fieldtype is generated at runtime. No data is saved in the database. The accompanying InputfieldRuntimeMarkup is only used to render/display the markup in the page edit screen. The field's value is accessible from the ProcessWire API in the frontend like any other field, i.e. it has access to $page and $pages. The module was commissioned/sponsored by @Valan. Although there's certainly other ways to achieve what this module does, it offers a dynamic and flexible alternative to generating your own markup in a page's edit screen whilst also allowing access to that markup in the frontend. Thanks Valan! Warning/Consideration Although access to ProcessWire's Fields' admin pages is only available to Superusers, this Fieldtype will evaluate and run the custom PHP Code entered and saved in the field's settings (Details tab). Utmost care should therefore be taken in making sure your code does not perform any CRUD operations!! (unless of course that's intentional) The value for this fieldtype is generated at runtime and thus no data is stored in the database. This means that you cannot directly query a RuntimeMarkup field from $pages->find(). Usage and API Backend Enter your custom PHP snippet in the Details tab of your field (it is RECOMMENDED though that you use wireRenderFile() instead. See example below). Your code can be as simple or as complicated as you want as long as in the end you return a value that is not an array or an object or anything other than a string/integer. FieldtypeRuntimeMarkup has access to $page (the current page being edited/viewed) and $pages. A very simple example. return 'Hello'; Simple example. return $page->title; Simple example with markup. return '<h2>' . $page->title . '</h2>'; Another simple example with markup. $out = '<h1>hello '; $out .= $page->title; $out .= '</h1>'; return $out; A more advanced example. $p = $pages->get('/about-us/')->child('sort=random'); return '<p>' . $p->title . '</p>'; An even more complex example. $str =''; if($page->name == 'about-us') { $p = $page->children->last(); $str = "<h2><a href='{$p->url}'>{$p->title}</a></h2>"; } else { $str = "<h2><a href='{$page->url}'>{$page->title}</a></h2>"; } return $str; Rather than type your code directly in the Details tab of the field, it is highly recommended that you placed all your code in an external file and call that file using the core wireRenderFile() method. Taking this approach means you will be able to edit your code in your favourite text editor. It also means you will be able to type more text without having to scroll. Editing the file is also easier than editing the field. To use this approach, simply do: return wireRenderFile('name-of-file');// file will be in /site/templates/ If using ProcessWire 3.x, you will need to use namespace as follows: return ProcessWire\wireRenderFile('name-of-file'); How to access the value of RuntimeMarkup in the frontend (our field is called 'runtime_markup') Access the field on the current page (just like any other field) echo $page->runtime_markup; Access the field on another page echo $pages->get('/about-us/')->runtime_markup; Screenshots Backend Frontend1 point
-
Hi I've been working on a site that needed a calendar. Specifically it needed a calendar with support for some rather iffy recurrence patterns. This is all still pretty rough but I have written two modules. Calendar : Implementes basic event recurrence expansion using four fields: calendar_start calendar_end calendar_rrule calendar_exdate these fields are created on install (but not removed!) and are added to the template: calendar-event which is created on install (but again not removed on uninstall!). the calendar-event template is intended to be expanded to represent the needed calendar event structure. The ProcessCalendarAdmin provides a calendar admin gui. the modules and a slightly more detailed readme can be found on github https://github.com/lindquist/processwire-calendar I'm not sure how much more time I can/will spend on this, so here it is in case anyone finds it useful1 point
-
Just in case anyone missed it... https://letsencrypt.org/2014/11/18/announcing-lets-encrypt.html The headline is: Let’s Encrypt is a new Certificate Authority: It’s free, automated, and open. Arriving Summer 2015 Extract: Let’s Encrypt is a new free certificate authority, built on a foundation of cooperation and openness, that lets everyone be up and running with basic server certificates for their domains through a simple one-click process. Mozilla Corporation, Cisco Systems, Inc., Akamai Technologies, Electronic Frontier Foundation, IdenTrust, Inc., and researchers at the University of Michigan are working through the Internet Security Research Group (“ISRG”), a California public benefit corporation, to deliver this much-needed infrastructure in Q2 2015. The ISRG welcomes other organizations dedicated to the same ideal of ubiquitous, open Internet security.1 point
-
On one site I added a little bit of code to just keep a track of page visits. For fun, I also added it to the 404 page. Over the last month I have had over 1000 hits to the 404, which made me wonder who was getting my site addresses so wrong. Obviously, this is a terribly course tool and does not tell me anything other than it is being hit. So, being curious, I chucked an email at the hosting provider, asking them if they had a clue from their logs (i am terrible at reading logs) Yes, they said. The vast majority of 404s are being caused by people trying to hit the following page: mydomain.com/wp-admin Now, what a surprise!1 point
-
Updated module on dev branch. New features for v.0.0.9 dev branch : Added hook method ___beforeRender(), you can check hook example for usage Added multiple icons library use option Added Ionicons Library Now module using cdn for load icon fonts Also if you need custom icon font options you can use berforeRender hook ! After some test i will update also master branch. if you want to make test, you need to download and update it manually.1 point
-
Good idea - though to be in keeping with the joke the module would have to demand weekly updates to avoid catastrophic bugs.1 point
-
Greetings, This is great news, as I have been spending a lot of time lately looking for SSL solutions for some of my sites. I'll be putting this SSL into place in some of my smaller sites and will report back on it later. LostKobraki: nice portfolio site. Although some of the shots made me forget what we were talking about! Thanks, Matthew1 point
-
Just in case someone new to PW reads this and does not know, where to look: "Homepage" in this context means the first page one on top of the page tree - click on "edit" and go to the tab "settings".1 point
-
@Macrura, Thanks for catching this. You will notice the same error if you tried to rename a FieldtypeConcat field. The error occurs because these Fieldtypes do not create a database table, i.e. there is no field_my_runtime_field table. MySQL throws the error since it can't find such a table on file, i.e. there is no field_my_runtime_field.frm file (every MySQL table is represented on disk by a .frm file that describes the table's format). It throws the error in Fields.php, in the __save() method, here. Although the method is hookable, I'll have a talk with Ryan to see what's the best way to handle this. Edit: Forgot to provide a temporary solution: As we know, the names of fields themselves are stored in the 'fields' table. As we wait to resolve this, we can always change a fields name there. Not ideal, I know, but we will get to the bottom of this. Edit 2: Issue fixed in this commit in ProcessWire 2.7.2 (dev)1 point
-
@Tom. I would also love to see those Pages, Setup, Modules, Access would honour their addresses and go to there when clicked. Exactly in the same manner as you've sketched.1 point
-
Hey Reno, with the new update removing the tree. The only way to access the page tree is by clicking the ProcessWire logo. It took me a while to figure this one out as I always went to Pages > Tree. With Pages > Tree now missing it might be worth doing: I know it's not as visually appealing so you may have a better idea Reno.1 point
-
You can always edit your module in the modules directory - simply open the edit mode and save - it will query Github and update the version number which will then make it available via the Upgrade module instantly.1 point
-
Sorry i missed to update Fieldtype and Markup versions. But you need to wait for PorcesswireModuleDirectory update repos or you can make update by downloading files from github.1 point
-
@modifiedcontent I am assuming you want to do this on the frontend of your website? in post #3 you can find the basic code that you need to create a user and the profile page for that user from the API side. In that code the profile page is created before the user page and the author uses to link the 2 pages together by the username which is unique and that should be ok. I'd suggest to first create the user and then the profile page and make the profile page owned by the user. I use this code to create user and profile page // sanitize input $uname = $sanitizer->pageName($registrationForm->get("uname")->value); $email = $sanitizer->email($registrationForm->get("regemail")->value); $fullname = $sanitizer->text($registrationForm->get("name")->value); $pass = $registrationForm->get("pass")->value; $timezone = $sanitizer->text($registrationForm->get("timezone")->value); // create new user $u = new User(); $u->name = $uname; $u->email = $email; $u->pass = $pass; $u->addRole("frontend"); // the specific role that you defined $u->save(); // create profile page $user = $users->get($uname); // get the user $users->setCurrentUser($user); // set the user as current user so he will own the profilepage $uid = $user->id; $p = new Page(); // new page is created and owned by the currently set user // set the template and parent (required) $p->template = $templates->get("userprofile"); // your user profile template $p->parent = $pages->get("/profile"); // the parent page for the user profiles // populate the page's fields with sanitized data $p->title = $uname; $p->name = $uname . "-" . $uid; // just to be sure that the name is unique $p->fullname = $fullname; $p->timezone = $timezone; $p->save(); Now the profile page is owned by the user. To make it only editable by that user, in your profile page template you can implement something like this (assuming the user is logged in) if($page->created_users_id != $user->id) { echo "You are not allowed to edit this resource"; } else { // render the user profile edit form } Above solution is kind of outdated. Because since PW 2.5.14 you can create alternate user templates with Multiple templates or parents for users that contain your custom fields. You can use these as userprofile pages. I'd recommend using these as they are easier to maintain with less code.1 point
-
how about wordLimiter? i have this in every single site.1 point
-
I'll be rolling this out to my personal site when I get some time. I never bothered to set up encryption on a one page business card site. I'll let you know if I have issues .1 point
-
Sorry i am to busy with work and i know the issue. I think this issue appear, because fonticonpicker js library changing the processwire field attributes. I will do one more hidden field for fonticonpicker js attributes and after done i will update processwire field. Started to work on it. Thanks for interest !1 point
-
I'll wait some time and see if there are any issues, especially with the tool they provide. If I need a new cert for any private site the next time I'll certainly give it a go.1 point
-
It depends: $pages->count() does work with a selector supplied, whereas $pages->find("some=Pages")->count() doesn't use any parameters, because pages are already loaded to a PageArray.1 point
-
Did you add the url name for each language on the homepage settings?1 point
-
@SiNNuT, thanks! I agree. I just like to have a fallback in case the summary field isn't filled in every time. @kongondo's code actually checks for a summary field first, and my imitation does likewise.1 point
-
Here we are Luis.... just set up a public repo: https://github.com/mr-fan/Officesuite Just created a exported siteprofile from a actual 2.7.1 PW version. So every one could install it simple as a site profile. Now the last question is the license and your permissions and wishes about that topic. May we should go with GPL or release it as simple Public Domain: http://choosealicense.com/licenses/ For me i think it could only stay as a example application for learning some stuff - the app itself can only used partly while some things in accounting and billing changed and everyone that use this app should care about this things (for example IBAN and BIC instead of banking accont number...) But it is your piece of work and it is your decision. @all - this is a german language application and for multiligual frontend we have to change every hardcoded string in the templates....so to a multilang working out of the box app some work is on the road...that i could not do alone. So every one that is interested in helping could send me a PM for further work on this - or every one could use it as it is... regards mr-fan1 point
-
I see more and more small businesses in my region focusing completely on Facebook and Twitter, but that depends always on individual budgets. Overall, there is a lot of competition out there in the form of drag-and-drop website builders, WordPress templates etc and not every business will value a custom-made website. In the end of the day, running a web-related business is 50% sales. You need to be able to sell and market your skills to potential clients. In this respect, larger agencies have more resources and account managers, which will aggressively sell their solutions. While larger corporations will many times prefer an agency, small- and medium-sized companies often like the flexibility and responsiveness of individual freelancers. It really depends on the target clients you want to focus on and the related budgets you realistically can achieve.1 point
-
Facebook might seem nice from the outside, but it's actually a damn lot of work to get any reach without paying facebook to advertise the company. Without regular (daily at best) posts you'll hardly get visitors beyond the people who actually know you already. The agency vs. single dev argument might be true, but that's the case for every single freelancer no matter of the industry. I think the best way to get along with that is a strong portfolio and optionally a small high quality set of partners and fellow devs (of other strengths), which you can rely on in bigger projects. Especially if they have a strong portfolio as well you can certainly assure clients that they'll get the same quality as they can expect from an similarly sized agency. Surely you can't do the job a whole team of people is doing in an agency, especially in a similar timeframe. So to get the really big projects one needs to have a critical number of people on board.1 point
-
Quickly tested this today (since I have need for it on one personal project). Very nice implementation and will definitely meet the criteria for my project. Few notices if lindquist or someone else goes further with this: - used new [] array syntax (but just once) - I removed that since I run on Ubuntu LTS (stuck with php 5.3 until update to 12.04). - no language tags (quick fix though) - recurring events are done by writing RFC5545 RRULE format, which is of course way too technical for most users. Does anyone know any JS plugin that would offer nice UI for that? Would make lovely inputfield. (This might be it: https://github.com/jkbrzt/rrule ) - sabre library is huge and only small subset of it is in use. Would some smaller library be enough, like these: https://github.com/tplaner/When or https://github.com/simshaun/recurr It was breeze to setup and works flawlessly. Admin ui is very snappy and easy to use. Nice work!1 point
-
Aenean lacinia bibendum nulla sed consectetur. Nullam quis risus eget urna mollis ornare vel eu leo. Cras justo odio, dapibus ac facilisis in, egestas eget quam. {video} Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. $search = '{video}'; $replace = "<iframe width='560' height='315' src='$page->your_field' frameborder='0' allowfullscreen></iframe>"; str_replace($search, $replace, $page->body);1 point