Leaderboard
Popular Content
Showing content with the highest reputation on 01/12/2016 in all areas
-
This is interesting https://www.wordfence.com/learn/2015-wordpress-security-survey/ It is an annual survey of 7000 plus members of the Wordfence community. I was particularly drawn to this line in the conclusion at the bottom: Since many clients coming to PW might well be coming from WordPress, this survey might be useful in client presentations.7 points
-
Hey suntrop, have you checked out the offical docs on HTML Purifier? You can set stuff like: $purifier->set('Core.Encoding', 'ISO-8859-1'); Also check out Ryans docs on the ProcessWire module.3 points
-
Hello @ all I want to share my code of a module which copies values from a parent page to a child page by using the add button of a pagetable field. If you find it useful you can copy the code or you can improve the code and post your ideas of improvement here. The intention for me was that I have pages with events and I dont want to write all the data for an event manually. Especially if only the date of the event is different. I use a pagetable field for the events and I want to click the add button of this field and a new childpage will be created with all the data of the event (title, description, summary,...) so I have only to fill in the start and end date for the event. So far so good, but it was a little bit tricky to get this to work with the add button of the pagetable field. So I decided to write a module which does the work for me. Here is the piece of code: <?php class CopyPageTableAdd extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Pagetable copy values', 'summary' => 'Copy Pagetable content by pressing the add button', 'href' => '', 'version' => 001, 'autoload' => true, 'singular' => true ); } public function ready() { $this->pages->addHookBefore('ProcessPageAdd::execute', $this, 'copyaddpage'); } public function copyaddpage() { //configuration $parenttemplatename = "events"; //the template name of the parent template $childtemplatename = "single-event"; //the template name of the newly created child template $page = new Page(); $page->parent = $this->input->get->parent_id; if ($page->parent->template == $parenttemplatename) {//check if it is the right parent template $page->template = $childtemplatename; //set the template for the created child page //copy all fields field values from the parent template (start) //enter all fields which you want to copy into the child page $page->title = $page->parent->title; $page->eventstatus = $page->parent->eventstatus; $page->eventtype = $page->parent->eventtype; $page->summary = $page->parent->summary; $page->headline = $page->parent->headline; $page->importanteventstext = $page->parent->importanteventstext; $page->importanteventstext = $page->parent->importanteventstext; $page->notifiable = $page->parent->notifiable; $page->reservationtype = $page->parent->reservationtype; $page->participantlimit = $page->parent->participantlimit; $page->participantmaxnumber = $page->parent->participantmaxnumber; $page->eventmaxstatus = $page->parent->eventmaxstatus; $page->eventcosttype = $page->parent->eventcosttype; $page->eventprice = $page->parent->eventprice; $page->eventpriceadd = $page->parent->eventpriceadd; $page->eventlocationname = $page->parent->eventlocationname; $page->street = $page->parent->street; $page->postalcode = $page->parent->postalcode; $page->eventlocationname = $page->parent->eventlocationname; $page->place = $page->parent->place; $page->region = $page->parent->region; $page->country = $page->parent->country; $page->googlemap = $page->parent->googlemap; //copy all fields field values from the parent template (end) $page->addStatus(Page::statusUnpublished); //this foreach loop is only if you have a multilanguage site to get the path names in each language //if your site is only single language you can use $page->name=$page->parent->name (but not tested) foreach ($this->languages as $lang) { $lname = $lang->id; $pageName = $page->title->getLanguageValue($lang); $page->set("name$lang", $pageName); if ($lang->isDefault()) continue; $page->set("status$lang", 1);//activate the multilanguage checkbox } $page->save(); $this->session->redirect("../edit/?id=$page"); } } } The configuration part: //configuration $parenttemplatename = "events"; //the template name of the parent template $childtemplatename = "single-event"; //the template name of the newly created child template This is the part where you have to define the templates. The name of the parent template is responsible that the module only run on that template (in my case the template with the name "events). The name of the child template ist the template which should be created after pressing the add button (in my case the template with the name "single-event"). You have to fill in your template names. The module runs only if the parent template has the specific name and creates only child pages with the child pages template name. Copy all field values par: //copy all fields field values from the parent template (start) //enter all fields which you want to copy into the child page $page->title = $page->parent->title; $page->eventstatus = $page->parent->eventstatus; $page->eventtype = $page->parent->eventtype; $page->summary = $page->parent->summary; $page->headline = $page->parent->headline; $page->importanteventstext = $page->parent->importanteventstext; $page->importanteventstext = $page->parent->importanteventstext; $page->notifiable = $page->parent->notifiable; $page->reservationtype = $page->parent->reservationtype; $page->participantlimit = $page->parent->participantlimit; $page->participantmaxnumber = $page->parent->participantmaxnumber; $page->eventmaxstatus = $page->parent->eventmaxstatus; $page->eventcosttype = $page->parent->eventcosttype; $page->eventprice = $page->parent->eventprice; $page->eventpriceadd = $page->parent->eventpriceadd; $page->eventlocationname = $page->parent->eventlocationname; $page->street = $page->parent->street; $page->postalcode = $page->parent->postalcode; $page->eventlocationname = $page->parent->eventlocationname; $page->place = $page->parent->place; $page->region = $page->parent->region; $page->country = $page->parent->country; $page->googlemap = $page->parent->googlemap; //copy all fields field values from the parent template (end) This ist the part where you can fill in all fields which you want to copy the values. It copies the values from the parent page to the child page. You can do this also with a foreach loop, but I dont want to copy all field values so I write it manually for each field. The multilanguage part: foreach ($this->languages as $lang) { $lname = $lang->id; $pageName = $page->title->getLanguageValue($lang); $page->set("name$lang", $pageName); if ($lang->isDefault()) continue; $page->set("status$lang", 1);//activate the multilanguage checkbox } The multilanguage part is necessary if you have a multilanguage site, because it creates the path names for each language in the right language. After that the multilanguage checkbox for the non default language should be checked to activate the page in this language. Here are some screenshots: 1) Press the add button of the pagetable field 2) A new child page will be created with prefilled values of the parent page 3) Path names are in the right language and multilanguage checkbox is activated So this might be useful for others Best regards2 points
-
Hello fellow ProcessWire devs. I recently developed and launched the following site: http://whiteconst.com/ Specs: PW 2.4 Zurb Foundation 5 Full width layout + responsive design; font-scaling in certain situations Ajax page loading; window history pushstate CSS3 based loading animations (page to page, project modal) Heavily animated home page slideshow (built with sequencejs) Developed so that every page is properly indexed by search engines despite used of Ajax (each page has it's own unique URL; canonical meta tags also indicate to search engines what the official URL of a page is to prevent duplicate content cases) Form Builder module Hanna Code module XML Sitemap module Video Embed for YouTube/Vimeo module (don't know about this one? you should!) Custom module to that allows administrators to view all projects in the admin section using a table layout with more metadata screenshot: http://goo.gl/3HfJTW Custom modal to view projects Custom developed news blog (with categories, year archives, recent posts filters) Content is easily manageable by site admins All kinds of frontend coding to make the layouts look great, especially the project pages (image gallery, videos, etc.) This was a challenging project for several reasons. Several requirements and layouts were changed along the way. Also, whenever dealing with Ajax based page loading, that seems to complicate things by a factor of 3 (must take many other things into consideration for it to work properly and lots of edge cases). This was also the first PW site I did that needed a blog / news section. I didn't start with the Blog profile, but this was easy to roll. In fact, I like being able to build out the blog myself because of the greater control it provides. I wanted URLs to be formatted in a particular way. It needed to be Ajax based. I like naming things my own way (Blog or News? Post or Article?... WordPress's defaults are extremely confusing to the end user). At the end of the day, ProcessWire was a perfect fit for this project. - Jonathan2 points
-
Update: Version 4 Up on GitHub Changes In addition to the using a custom selector to filter for selectable page markers, you can now also use custom PHP Code. NOTE: (a) Custom PHP code will only work with the Asm Select page selector option. (b) Custom PHP code overrides custom selector if set Will submit to Modules Directory once I have done the README (might take a while...) ps: Updated first post to reflect current status...2 points
-
Updated to the latest version to test callouts. Looks great. With short names as in this particular use case, callouts greatly improve usability. BTW, should probably update the description on the first post in this thread: "one can only choose from one type of marker (circle) at the moment". No longer the case.2 points
-
Maybe the admin themes could feature a hook in that place so it could be edited without modifying core files.2 points
-
You could also get ProcessWire to handle duplicate cases for you. $p = new Page(); $p->name = uniqid(); ... $p->save(array('adjustName' => true)); From the API function:2 points
-
2 points
-
I know this has been discussed in detail over the years and I read everything I could find about it in the forum. And still, no (straightforward) solution to my scenario. My situation: I set up a multilingual events directory site were instructors can sign in and manage their events. There is a core content area which is available in 4 languages. Instructors post their personal info and their events in only one language, but field labels need to be multilanguage. Therefore I need multilanguage page names and fields for them, too. The site has been running on Joomla/Seblod for 3 years already. I am currently in the process of porting it to PW. Once this is done, a skeleton of the site will be rolled out in different EU countries, so instructors in those countries have their own PW install to manage events for their country. Of course, the default language needs to be a different one in each country. And this is where my problem lies. I have the multilanguage setup with Language Support Page Names module and am working with multi-language fields in a 2.6.23 install. In the original project, the default language is English. Now I need to make a copy of the site that has German as default. Solutions that I am aware of are: 1. do a redirect for the default language homepage. For the frontend this is fine except for the /de/ appended to the home page. In the backend, the German users have language German. But German is not the default language. So when a user creates a new event, they will be presented with the German tab open for multi-language fields. When they fill in the title (PageTitleLanguage) and hit save, they get an error "Required value missing" for the title field. Because they only fill in the german title and the default (english) title is still empty, hence the error. So this is actually not a solution. 2. switch the values for multi-language fields by script (like proposed here) and rename the default's language title to "German" and adjust the URLs in the page names of the home page. While this is doable, it requires quite some effort as I will have to do this for every country. In Joomla/Seblod I can just change the default language with one click in the backend. And I am very much missing this feature in PW Finally, my question: Is there any way other than solution 2 to handle the situation? Maybe I missed some new features or maybe someone has come up with a way to truly change the default language programmatically. Thanks for reading through all of this. Any help would be very much appreciated.1 point
-
I'd like to thank LostKobrakai for this excellent tutorial included in the Dec 25, 2015 blog post regarding custom page types. If you haven't read it yet, please do so. It is contributions like this by the senior members that prove selecting ProcessWire was the correct decision for this ProcessWire-Newbie. I am impressed at what I have learned within the functionality of ProcessWire, and discovering avenues I hadn't yet thought about. It is indeed a merry Christmas. I also want to thank all staff members. They deserve our gratitude for the time they dedicate to helping us learn ProcessWire, and the many avenues available with each project. For example, kongondo contribution is another great example of the team in place here. My hat is off to Ryan and his team for giving of their time and sharing their knowledge. In addition to the regular staff, there are many members, such as Kixe, Tom, (and too many others to name them all here) that also deserve recognition for their contributions and assistance. It is greatly appreciated. I am certainly looking forward to ProcessWire 2016 ;-)1 point
-
This week is all about repeaters, something that we didn't cover on the roadmap last week–we always like to save a few surprises to keep things interesting. We've also got a preview of the new Repeater Matrix field coming soon to the ProFields package… Read the post here: https://processwire.com/blog/posts/processwire-3.0.4-repeaters-revisited-preview-of-profields-matrix/1 point
-
And the most used plugin types are security based. Because you'd need em, right?1 point
-
InputfieldSelector is build to be a GUI for building page selector strings and is therefore quite specialized to that job. But you could always take a look into the files of the module and see if you can reconstruct the parts you need (e.g. all the ajax things are probably not needed).1 point
-
The homepage does work because apache does simply call the index.php without arguments, whereas the .htaccess does convert urls to something like index.php?it=/path/ which is still the same file.1 point
-
You can do it in the module. Here is the code of an module which changes the path names for multilingual site. <?php /** * * ProcessWire 2.x * Copyright (C) 2014 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://processwire.com * */ class CorrectPagenames extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'CorrectPagenames', 'version' => 1, 'summary' => 'Output custom path names multilingual', 'singular' => true, // Limit the module to a single instance 'autoload' => true // Load the module with every call to ProcessWire ); } public function init() { // init() is called when the module is loaded. // saveReady is a hook after processing the previous changes of the page, // but just before those changes are saved to the database. // It's called for each page that's being saved, no matter if it's in // the backend or in your templates via the api. $this->addHookBefore('Pages::saveReady', $this, 'beforeSaveReady'); } public function beforeSaveReady($event) { $page = $event->arguments[0]; //create custom path name for children events $datestart = $page->publish_from; // I use the publish from date for the path name $datestart = date('Y-m-d', $datestart); $eventtitle = $page->parent->title; // I also use the parent title for the path name $page->name = $eventtitle . '-' . $datestart; //putting it all together for the default language foreach ($this->languages as $lang) { //multilanguage starts here if ($lang->isDefault()) continue; $lname = $lang->id; $pageName = $page->title->getLanguageValue($lang); $pageName = $pageName . '-' . $datestart;// create custom path for other languages $pagelanguage = "name" . $lang; $page->$pagelanguage = $pageName; //this sets the path name for each language } } } You can take a look on how to achive it (as an inspiration ) Best regards1 point
-
I would like to include my thanks too, LostKobraKai, Kongondo, Adrian, Ryan and all the others i can't name now. This forum's great for newbies like me. It can be really overwhelming and irritating to code sometime, but in the end you always get there with the help of the generous staff-members. Thanks again! All the best Jakob1 point
-
Looks good, only thing I would check is: You probaply will give a name and / or title to your new page. I would suggest to create it first and check if a page with that given name or title already exists: $parent = wire('pages')->get('/site-manager/bookings/'); $genericTitle = $somehowCreatedFromYourDataOrTimestampOrWhatever; $p = $pages->get("title={$genericTitle}, template=booking, parent.id=" . $parent->id); if(0 == $p->id) { // page does not exist, we can create a new one $p = new Page(); // create new page object $p->template = 'booking'; // set template $p->parent = $parent; $p->title = $genericTitle; ...... } else { // UUUPs! A Page with that title exists. // This case must be handled different! ...... }1 point
-
I read a bit more into MUUT and they just keep their database totally separate, so the users only exist in the CMS you choose. So basically, if you ever switch CMS, you would need to convert your user accounts to a new CMS and change the MUUT user array data to the new CMS' variable. Not a big deal actually. What I meant by the $user conflict is you can't have two things called $user. $user is reserved in ProcessWire, so not sure what the options are there. There also doesn't seem to be anything in the index.php you posted above that actually does anything to do with MUUT, however now I say that I see the JS at the end that points to the URL of the MUUT forum, so maybe it's passing some variables via JS? The reason I asked about index.php is because in ProcessWire you don't do any templating in the root index.php file. You edit the templates in /site/templates/ instead. I think, whichever CMS you ultimately settle on to work with MUUT, you need to understand the CMS you're using and how it works first, so read some tutorials, look into the docs and watch the overview video (quite out of date now, but gives you an idea of how things work). I'm also concerned when you say you have time constraints - what you're attempting to do isn't simple if you're not au fait with both systems, though top marks for diving in at the deep end and giving it a go1 point
-
As any javascript feature you can surely use this with processwire. Nobody does care how you create your markup and if it comes from an index.html or any server side scripting.1 point
-
@mr-fan Soma's solution does already strip tags.1 point
-
wow the original post was like 3 years ago... i think if i was doing this now i would probably go with javascript cookie, since i tend to do a lot more server side caching over the last years;1 point
-
Yeah the whole wakeup/sleepValue topic is a bit hidden in the code. Here's wakeupValue https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Page.php#L605 and here's sleepValue (kinda) https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Pages.php#L1252. And sanitizeValue is always called when a value is set to the field, so it's also called when your inputfield's data are set to the field when saving the page.1 point
-
Here you go. Images need to go into /site/templates/ImageSelect/[path/] and must be named [optionValue].jpg. For usage with FieldtypePage you need to add the module in the settings of InputfieldPage. For the newer options fieldtype it's available right away. Edit: My version might be more suited to the usecase of presenting layout options to the admins, rather than having a full blown thumbnail display. Archiv.zip1 point
-
Or this: class InputfieldSelectThumbnail extends InputfieldSelect { /** * Return information about this module * */ public static function getModuleInfo() { return array( 'title' => __('InputfieldSelectThumbnail', __FILE__), // Module Title 'summary' => __('Select a page from a list that displays a thumbnail of the first image found in the page', __FILE__), // Module Summary 'version' => 101, 'autoload' => true ); } public function init() { $this->addHookBefore("InputfieldPage::getConfigInputfields", $this, "addOwnClassToSelect"); } public function addOwnClassToSelect($event) { $obj = $event->object; $classes = $obj->get("inputfieldClasses"); $classes[] = "InputfieldSelectThumbnail"; $obj->set("inputfieldClasses", $classes); $this->log->message("addOwnClassToSelect: InputfieldSelectThumbnail"); } protected function renderOptions($options, $allowBlank = true) { $out = ''; reset($options); $key = key($options); $hasBlankOption = empty($key); if($allowBlank && !$this->required && !$this->attr('multiple') && !$hasBlankOption) $out .= "<option value=''> </option>"; foreach($options as $value => $label) { $selected = $this->isOptionSelected($value) ? " selected='selected'" : ''; $attrs = $this->getOptionAttributesString($value) . " " . $this->getThumbnailAttributes($value); $out .= "\n\t<option$selected $attrs value='" . htmlspecialchars($value, ENT_QUOTES, "UTF-8") . "'>" . $this->entityEncode($label) . "</option>"; } return $out; } protected function getThumbnailAttributes($pgid) { $this->log->message("getThumbnailAttributes({$pgid})"); $pg = $this->pages->get($pgid); if( $pg instanceof NullPage ) return ""; $fields = $pg->template->fields; $imgfield = null; foreach($fields as $fld) { if( $fld->getInputfield($pg, $fld) instanceof InputfieldImage ) { $imgfield = $fld; break; } } if( $imgfield == null ) return ""; $img = $pg->get($imgfield->name); if( $img == null ) return ""; if( is_array($img) ) { if( count($img) == 0 ) return ""; $img = $img[0]; } else if( $img instanceof WireArray ) { if( $img->count() == 0 ) return ""; $img = $img->first(); } $thumb = $img->size($this->maxThumbWidth, $this->maxThumbHeight); $width = $this->maxThumbWidth + 4; $height = $this->maxThumbHeight + 4; $attrs = "style='padding-left: {$width}px; height: {$height}px; background-image: url({$thumb->url}); background-position: 2px 2px; background-repeat: no-repeat;'"; return $attrs; } public function ___getConfigInputfields() { $inputfields = parent::___getConfigInputfields(); $fieldset = $this->modules->get('InputfieldFieldset'); $fieldset->label = $this->_('Thumbnail options'); $fieldset->attr('name', 'thumboptions'); $fieldset->icon = 'image'; $field = $this->modules->get('InputfieldInteger'); $field->label = $this->_('Max. width'); $field->attr('name', 'maxThumbWidth'); $field->attr('value', $this->maxThumbWidth ?: 80); $field->columnWidth = 50; $fieldset->add($field); $field = $this->modules->get('InputfieldInteger'); $field->label = $this->_('Max. height'); $field->attr('name', 'maxThumbHeight'); $field->attr('value', $this->maxThumbHeight ?: 80); $field->columnWidth = 50; $fieldset->add($field); $inputfields->add($fieldset); return $inputfields; } } If picked as the input field type for a page field, it adds a thumbnail from the first image found in each selectable page to the dropdown (by resizing that image and setting it as the option's background image through css).1 point
-
I have to hop in on this and portray my thanks to LostKobraKai and everyone else on this forum! Everyone is so helpful and (and luckily for me) ignores my dumb/simple questions to help me out. As someone still learning php and processwire, it can be overwhelming trying to achieve what is in my head with the limited knowledge that I have thus far.1 point
-
// set new default language $default = $languages->get('german'); // redirect if (!$user->isLoggedin() && $page->localUrl($default) != $page->url) $session->redirect($page->localUrl($default));1 point
-
1,5 month later, after I did most of the project and be sure that I understand PW system, I finally finished that part. It's not perfect of course but it's working fine. Here is how I did it: Templates And Fields: I created 2 templates: grid and grid_item and 1 pagetableextended field grid_items. In grids page I can enter grid_items like below: Title, summary, featured_image for content on the grid items, external url for obvious reasons, grid_ratio is to determine size of item. Design is limited with ratios from 1x1 to 3x3, so I made it selectable page items from options use_border : for images with white bg, so they don't look like they are floating Modules I have created 3 modules. InputfieldGridBuilder,FieldtypeGridBuilder and GridBuilder. Whenever I save the page, new items from grid_items pagetable are available to use like below. I can order items, add new rows, delete row etc. Whenever I change something, there is a method that works to serialize data to the hidden input field,InputfieldGridBuilder. Also, just in case I call the function it every 5 seconds. I make a small fixed grid that is very similar to the one used in the frontend. So anything that you can do here with jQueryui sortables, it's available for using in the frontend. Last module GridBuilder is used for mostly utility purposes for both frontend and backend. It has methods like getItemSize, getItemImage, build etc. Frontend Normally these will be used in homepage but I made the view of page available to users with editing roles, so before using them they can see that it look like. For example this one in the gif above looks like this. So even with the empty rows, it works. And for using in the homepage, I added a multiple selection page field. So they can use more than one grid, or with the location options we already added they can select to have a different view for different countries. (I added Location settings is globally for every page) Questions, critics, feedbacks or "hi,there buddy"'s are highly welcomed.1 point
-
Looking into this further... CKEditor widgets does seem like a superior approach... much better than Content Templates (which I mentioned in my last reponse) since with Widgets, the HTML structure is locked and easy to reposition. Very "page builder" like interactivity. There's some activity with Drupal and CKeditor Widgets that looks nice: http://albatrossdigital.com/node/41 CKEditor also has demo: http://ckeditor.com/demo#widgets A combination of CKEditor Widgets + ProcessWire tie-ins would be pretty slick.1 point
-
Oneliner alarm <?php if(!$session->noPop) include("./popup.inc"); $session->noPop = 1; ?> No intendation1 point