Leaderboard
Popular Content
Showing content with the highest reputation on 01/08/2016 in all areas
-
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/13 points
-
Video clip showing latest development...(note: previews of other types other than images are still a work in progress...)11 points
-
Fieldtype and Inputfield ImageMarker As of 02 January 2018 ProcessWire versions earlier than 3.x are not supported Version: Stable Project Page: Github Modules Directory: http://mods.pw/Bk OR http://modules.processwire.com/modules/fieldtype-image-marker/ Requires: ProcessWire 2.4 or greater ######################## About This module allows you to easily 'place markers' on an image. Each placed marker's position/coordinates (x and y) are saved in the field as well as the ID of the ProcessWire page the marker refers to. In the backend markers are placed on a specified base image. In the frontend, using each saved page ID you can then retrieve any information you want about the pages being referenced and display that on your website over the same base image you used in the backend. The module is useful for a diverse number of uses including: Product demonstration: place markers on various parts of your product to showcase its features. Using a bit of CSS and/or JavaScript you can create pop-up boxes displaying more information about that feature of the product. The information (in this case, feature), would be information you've stored in some field (e.g. a text field) in the page marker (i.e. the page being referenced by the coordinates). Office locations: place markers on a map showing global offices of a multinational company Points-of-Interest: place markers showing points of interest on a map or location or anything. The coordinates are saved as percentages. This means they will scale well with the image being marked. This module came about as a result of this request. @credits Ryan Cramer: This code borrows from his FieldtypeEvents. @credits Helder Cervantes: Module concept, HTML, CSS, JavaScript. @credits Roland Toth: CSS, Inspiration. API In the frontend, the field returns an array of ImageMarker objects. Each of these has the following properties info (integer): The page ID of the marker (i.e. the page being referenced by the marker. Using this, you can get the referenced page and have access to all its data. infoLabel (String): The title of the page (above) referenced by the marker (runtime only). x (Integer): The x-coordinate of the marker (%). y (Integer): The y-coordinate of the marker (%). You grab the properties as in any other PW field, e.g. $out = '<img src="'. $page->base_image->url . '" alt="">';// image to place markers on 'base_image' is the name of the file field foreach ($page->marker as $m) { // do something with the following properties $m->id;// e.g. $pages->get((int) $m->id); $m->x; $m->y; $m->infoLabel; } // the CSS and HTML are up to you but see InputfieldImageMarker.module for examples Frontend implementation is left to you the developer/designer8 points
-
This kind of error is usually because your code is overwriting the PW $user object. Try making your own user and password variable something like $u and $p, then there is no chance of that happening.6 points
-
I have had this too and it is also reported on Github. The error comes from other third party admin modules that try to fetch the id of the currently edited page in admin. The error is raised because those third party modules blindly assume the id is an integer value and passes it unsanitized, for example, via $pages->get($input->get->id). That will raise those errors. Very hard to debug and detect is such a unsanitized selector request when it is called in a autoloaded modules ready event! I have submitted a patch / pull request for that issue on github. PS: Devs of third party modules that need to fetch the currently edited page can do it at least like: $p = $pages->get('id=' . $input->get->id); // but better validate the id before using: if(!is_int($input->get->id) && !is_numeric($input->get->id)) return false; // or only using is_int() ?? if(is_int($input->get->id)) { $p = $pages->get('id=' . $input->get->id); . PPS: I have to admit that I had done it wrong too in some of my custom modules.4 points
-
I love what you've done GUI wise to... you removed the unnecessary space the old repeater took and making these not only more beautiful but also more practical. Awesome work !3 points
-
Tell me about it! 3.0 is going to be awesome! Every time I think ProcessWire is perfect, Ryan keeps proving me wrong by improving it Keep proving me wrong Ryan!3 points
-
2 points
-
Have you instead of php.ini tried putting the settings in a file called .user.ini placed in your public_html? I mention this because i see a reference to this in the phpinfo().2 points
-
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.zip2 points
-
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).2 points
-
I would probably add it to the picture template. Main reason is that it may be easier in the future if you introduce a different page template that also needs favourite functionality.2 points
-
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
-
@SiNNut That succeeded in changing the local values in my phpinfo() and it didn't crash the site. Thanks! Still having an issue with some uploads, but that's probably a topic for another thread.1 point
-
They are beautiful, both, the new repeaters and the matrix. Beautiful!!1 point
-
@Tom it looks like the server is cgi/fastcgi so i don't think you can do php value in htaccess, this will also cause 500 errors.1 point
-
1 point
-
if($session->login($user, $pass)) { // login successful $session->redirect($homepage->url); } else { // login error $session->login_error = 'Login Failed. Please try again, or use the forgot password link below.'; } may be is causing an error put them in a try catch block try { if($session->login($user, $pass)) { // login successful $session->redirect($homepage->url); } else { // login error $session->login_error = 'Login Failed. Please try again, or use the forgot password link below.'; } } catch (Exception $e) { wire('log')->save('debug', $e->getMessage()); }1 point
-
well there is this: http://modules.processwire.com/modules/template-preview-images/ and then you could probably clone the radio inputfield and integrate something with this: https://rvera.github.io/image-picker/1 point
-
You can use the WirePDF module with any kind of markup you need. I'm using wireRenderFile() to render the html with custom data and then pass it into WirePDF.1 point
-
Yes I confirm, I uninstalled the module and reinstalled again and the error gone, sorry for that.1 point
-
Just a note to everyone, Jumplinks doesn't appear to be compatible with 3.0.3. I had it working on 3.0.1 and 3.0.2, but did not test with 3.0.3. In the meantime, I'm dropping the PW3 compatibility tag until I am 100% certain everything works. Scratch that. It is actually working. It was an error that appeared only once, and then disappeared. I believe it has something to do with namespacing or file compilation. Can't be sure as yet. So support for current devns is there, just prepare yourself for the odd warning or error here and there (though, I don't think there will be many).1 point
-
There's no way to hook anything in regards to the session starting. This all happens in processwire's bootstrap part, before even the earliest hooks would run. But with Ryan having a processwire javascript api on the roadmap it may be time to discuss if pw 3.0 shouldn't support authentication without session.1 point
-
Not sure what's going on with my previous post. I've deleted it...Will update with short video instead...1 point
-
@benbyf You might find this class useful if you want to introduce the classic way of php debugging: https://processwire.com/talk/topic/4550-debugging-tips/?p=110290 Another thing that might be of interest is a short introduction to the main components of ProcessWire. What important building blocks are used in the CMS/framework, what they are for, how they work together, and which ones should be further studied as starting points, how modularity is implemented (CMS vs CMF). Such as: message system, logging system, 3.x compilation, wire calls, etc... Something similar: cms architecture diagram And links to Ryan's blogpost or other related doc pages for further study. I have not found anything similar so far, and it would help me a lot, I'm sure1 point
-
I have further refined this class. For instructions, you can read the comments in the code, or this: https://processwire.com/talk/topic/11782-pw-tuts-elsewhere-on-the-web/?p=110131 <?php namespace ProcessWire; /** * Flog.php: Can be used to inspect variables for debugging purposes. * * Example usage: * - If NOT running ProcessWire 3.x or higher, remove namespace ProcessWire; * - Create a directory called lib in your /site directory and put Flog.php into it. * - Insert this line into config.php: require_once(dirname(__FILE__).'/lib/Flog.php'); * - In the case of frontend debugging, start the rendering of the output * by calling Flog::init() before your code does anything else (for example * it could be the first line in your _init.php). * * - example log entry for PHP 5.5.x and below: Flog::log($page->children(), 0, 'kids', __FILE__, __LINE__); * - example log entry for PHP 5.6.x and above: Flog::log($page->children(), 2, 'kids', __FILE__, __LINE__); * * TIP: Use a shortcut to insert this code snippet into your code: Flog::log($var, 0, '', __FILE__, __LINE__); * then edit the first three parameters accordingly. Read all the other notes below for more information. * */ class Flog { protected static $name = 'flog'; // name of the log file protected static $firstSave = true; // no variables have been logged so far? /** * Initializes the class. Call it once before you start calling Flog::log() * The log file can be found in /site/assets/logs/flog.txt (assuming $name = 'flog') * */ public static function init() { if(!file_exists(self::filename())) { self::log('f-log debug file created...'); } @ini_set('error_log', self::filename()); // so that the same file is used for runtime errors as well } /** * Call Flog::log($my_variable) to log a variable. * * NOTE: the Wire class customizes the output of print_r (__debugInfo) when running on PHP 5.6+, so the $print_r * parameter can be used to output objects this way. * * @param mixed $var Any variable or expression to be logged. * @param 0|1|2 $print_r 0: print_r is not used, 1: print_r's output in one line, 2: formatted print_r output. * @param string $info Any string that helps identify the output, such as a variable name. * @param string $file Should be __FILE__ to identify the caller. * @param string $line Should be __LINE__ to identify the caller's line. * */ public static function log($var, $print_r = 0, $info = '', $file = '', $line = '' ) { $type = ''; $pretty = false; $php56plus = version_compare(PHP_VERSION, '5.6.0') >= 0; if (gettype($var) != "object") { $type = "[".gettype($var)."]"; } else { $print_r >= 1 && $php56plus ? $type ='' : $type = "[".get_class($var)."]"; } if (is_array($var)) { $var = json_encode($var); } elseif ($print_r >= 1 && is_object($var) && $php56plus) { if ($print_r == 1) { $var = print_r($var, true); // reformat whitespaces: $var = preg_replace('/\s+/s', ' ', $var); $var = str_replace(" => ", '=>', $var); } else { $pretty = true; } } if (self::$firstSave) { self::$firstSave = false; wire('log')->save(self::$name, "________________________ Flog.php _______________________"); } if ($file) { $file = basename($file, '.php'); } if ($pretty) { error_log(print_r($var,true)); // works in PHP 5.6.x and higher } else { wire('log')->save(self::$name, "$file $line $info $type $var"); } } public static function filename() { return wire('log')->getFilename(self::$name); } public static function name() { return self::$name; } }1 point
-
Just wanted to report my findings. session_name($config->sessionName); session_write_close(); does not have the desired effect. Sessions remain open. session_name($config->sessionName); session_write_close(); session_destroy(); throws a Warning: "Warning: session_destroy(): Trying to destroy uninitialized session" What I think happens, is that "session_name($config->sessionName);" does not capture the original PW session. If I do $_SESSION = array(); session_destroy(); the Sessions get destroyed and are not recorded in the DB anymore. I s there a way how I can get the PW session other than with $_SESSION? EDIT: looking at var_dump($session), it is all protected properties.1 point
-
Sorry, I'm on my phone so bare with me. $results = $pages->get("/")->children("template=events|articles"); foreach($results as $result) { echo $result->title; foreach($results->children as $child) { echo $child->title; foreach($child->children as $child) { echo $child->title; } } }1 point
-
Greetings, A lot of you probably already know about this, but just wanted to post here because I think it's really neat. The New York Public Library has prepared a page with free access to 187,000+ historic images, all in high-resolution. Check it out... http://publicdomain.nypl.org/pd-visualization/ Thanks, Matthew1 point
-
1 point
-
Hi Spica At my company, I've needed the same functionality so I've been trying to work it into the module. It pretty much works, but I'm not sure if this is the best way to modify the fieldtype module to work like this with a 'virtual' field and multiple selectors - it seems like a bit of a hack. It will also order results by distance regardless. https://github.com/CloudDataService/FieldtypeMapMarker/tree/develop I apologise for the formatting/whitespace diff. Example - assume the MapMarker field is called 'geo', I would search like this to get all 'place' pages where the map marker is within 30 miles of lat/lon 54.97,-1.62. template=place, geo.unit=mi, geo.distance<30, geo.point_lat=54.97, geo.point_lng=-1.62 In the results, you can display the distance like this: // Centre of the search area: $lat = 54.97; $lng = -1.62; $results = $pages->find("template=place, geo.unit=mi, geo.distance<30, geo.point_lat={$lat}, geo.point_lng={$lng}"); foreach ($results as $result) { // Calculate distance between result's marker and our search centre $distance = round($result->geo->distance($lat, $lng, 'mi')); echo "<li>{$result->title} ($distance miles away)</li>"; } ?> Hope it helps anyway.1 point
-
Thank you for the screencast kixe! Isn't it doing the same like the awesome https://processwire.com/talk/topic/9857-module-page-field-edit-links/ ?1 point
-
Sorry Jon - just realized I didn't answer the last part of your question. To read more about ready.php, take a look here: https://processwire.com/blog/posts/processwire-2.6.7-core-updates-and-more/ I think it is much easier than setting up a module for custom tweaks like this and I don't think there are any disadvantages. Actually, for admin specific stuff (assuming you aren't saving your pages via the API), you might actually want to put that code in /templates/admin.php so it is only called on the backend.1 point
-
Hi. I got the same problem here. It was some caching it seems.. If I logout the backend account and enter via private browser mode, everything should work. If not: Strg/Cmd+R for browser reloading.1 point
-
@kixe I think if modules should work under 2.7 and 3.0 without code changes they need to be without namespace.1 point
-
here ryan talks about session in site/config.php https://processwire.com/talk/topic/142-make-session-start-in-session-overridable-from-a-module/#entry1002 maybe this code could be put in config.php. session_name($config->sessionName); session_write_close();1 point