Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/22/2016 in all areas

  1. You could also override the javascript name checker so that you could warn users before they save the page. Take a look at this module: https://github.com/adrianbj/PageRenameOptions which also overrides that JS - it might help to get you started on the right path more quickly. Obviously this approach should be in addition to server-side checking, rather than a replacement for it
    3 points
  2. Created a PR: https://github.com/processwire/processwire/pull/38
    3 points
  3. @ethfun, if I understand right you would like to validate the page name during the Add Page process. This ought to be possible with a hook to ProcessPageAdd::processInput or InputfieldPageName::processInput, but stuffed if I can get PW to give a field error and return to Add Page; the error is displayed but the page is still added. I thought you could set an error to the inputfield... $my_field->error('That value is not allowed'); ...and the form wouldn't validate but I can't get that work for Add Page. Hopefully someone knows how to do this. BTW, members without a Form Builder license will not be able to read the thread you linked to with the background info. Might be good to include the details here.
    3 points
  4. This is our latest site using PW. Most of the grunt work is done with core modules but ProCache makes sure everything is super fast and the core image resize function was deployed everywhere an image is used to make sure everything stays looking good. The site uses a premium theme for it's graphical layout with colours and some typography changed to match the companies in-house style. Page templates themselves are hybrids using bespoke collections of the content blocks in the theme. A 'site settings' page is was added to the admin which collects and allows edits to site wide details such as phone number, email, GA code and main menu items etc. Comments welcome! http://www.brownhensolutions.com/
    2 points
  5. No, it's much simpler than that. You just add it once to the top of the file. <?php namespace ProcessWire; That's it - now there will be no need for the module to be compiled.
    2 points
  6. Hi, Done. https://github.com/processwire/processwire-requests/issues/56 Gideon
    2 points
  7. Just released a new version of this module! This module is now available without using the ProField : Table. The import for features is faster now you can import it to a textarea field. It is still available to import the features of the products to the ProField: Table if the user wants to.
    2 points
  8. https://processwire.com/blog/posts/hello-健康長壽·繁榮昌盛/ Sorry, that is page names, not filenames Now that we have UTF8 pagenames maybe it is time to revisit UT8 filenames. Perhaps a request on the github requests repo?
    2 points
  9. Ok well. I separated the assertions in their own class. And created a simple file for using the command line https://github.com/NinjasCL/ProcessServerAssert/blob/master/Assert.php just use php Assert.php in your server (or execute that file in the browser) and you can know if ProcessWire can run in the server
    2 points
  10. I have been using this module for a long time and it's been incredibly useful so I thought it was time to share. It's great for fields where you want to instruct content creators to reference something about a the page, its template, or its parent, or grand parent, etc Specify fields/properties of the page in your field's Description or Notes content, eg: [page.parent.url] [page.title] [page.template.label] You can also define a str_replace to be performed on the returned value, eg: [page.name.(-|_)] which will return the page name with the dashes replaced with underscores. An option to allow raw HTML is available. You can also use hanna codes within your description and notes fields - big thanks to @Robin S for this idea. http://modules.processwire.com/modules/dynamic-description-notes/ https://github.com/adrianbj/DynamicDescriptionNotes/ Hope you find it useful.
    1 point
  11. Here is a server-side alternative to (or backup for) the JS validation. $this->addHookBefore('ProcessPageAdd::processInput', function($event) { $form = $event->arguments('form'); $input = $this->input; $sanitizer = $this->sanitizer; $template = $sanitizer->int($input->post->template); if($template !== 43) return; // the ID of the template you want to limit page names for $name = $sanitizer->pageName($input->post->_pw_page_name); $parent_id = $sanitizer->int($input->post->parent_id); $uri = $_SERVER['REQUEST_URI']; $blacklist = ['cat', 'dog', 'hamster']; // your blacklist if(in_array($name, $blacklist) ) { $name_field = $form->children->get('_pw_page_name'); $error = "The page name '$name' is reserved. Please choose a different name."; $name_field->error($error); $this->session->redirect("{$uri}?parent_id=$parent_id"); } }); A little awkward but does the job. You could incorporate into a module to get a configurable template selection and name blacklist.
    1 point
  12. Welcome @AmilcarMarques, do you have the absolute urls in your template files? If yes, it is better to embed them using the $config->urls->templates method: <link rel="stylesheet" type="text/css" href="<?=$config->urls->templates?>styles/main.css" /> This generates a relative path to your templates directory, similar to the one in admin side. Regards, Andreas
    1 point
  13. I have made some major progress - but I could use some help for that last little push. @adrian, I've looked over your code for the PageRenameOptions module extensively, and apart from learning a lot, I am going to install that module on every single PW site I have. So thank you!! What I decided to do was to write a small module that handles this issue. See below: <?php use Helpers; class ProcessPageBlacklisted extends WireData implements Module, ConfigurableModule { protected $configFields; /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Blacklisted Pages', 'version' => 100, 'summary' => 'Creates an array of Blacklisted Pages that prevents the user from making pages that shouldn\'t exist.', 'href' => '', 'singular' => true, 'autoload' => true ); } /** * Init Function - loads scripts via hooks */ public function init() { // Add the Hooks to these two pages to add the JS $this->addHookBefore("ProcessPageEdit::buildForm", $this, "addScripts"); $this->addHookBefore("ProcessPageAdd::buildForm", $this, "addScripts"); } /** * Function to add the relevant Javascript to the Add and Edit Page screens */ protected function addScripts(HookEvent $event) { $conf = $this->getModuleInfo(); $version = (int) $conf['version']; return wire('config')->scripts->add( $this->config->urls->ProcessPageBlacklisted."ProcessPageBlacklisted.js?v={$version}" ); } public function execute() { $name = $this->wire('sanitizer')->pageNameUTF8($this->wire('input')->get('name')); if(!strlen($name)) return ''; $blacklisted_names = explode("\n", $this->data['blacklisted_names']); if(in_array($name, $blacklisted_names)) { $out = "<span class='taken ui-state-error-text'><i class='fa fa-exclamation-triangle'></i> " . $this->_('This name is not allowed!') . "</span>"; } return $out; } public function getModuleConfigInputfields(array $data) { $form = new InputfieldWrapper(); $f = wire('modules')->get('InputfieldTextarea'); $f->name = 'blacklisted_names'; $f->label = __('Blacklisted Page Names'); $f->value = $data['blacklisted_names']; $form->add($f); return $form; } } I'm making pretty heavy use of the ProcessPageAdd module, which has also been very helpful to look through. I copied the JS file from ProcessPageAdd and made a few changes to it, and I believe everything will work as planned once I figure out how to get the script to actually interface with the module itself through the execute() method. I keep reading Docs and different forum postings, but I'm stumped here. I expected that having a class called ProcessPageBlacklisted would be reachable through "admin/page/blacklisted", the output of the page being created by execute(). Apparently, I'm wrong. The javascript looks at what's in the name box, does an ajax call to "admin/page/blacklisted", and returns: ` {"error":false,"message":"Unrecognized path"} ` Can someone tell me what I need to do in order to get the output from the execute() function? Thank youuuuu...
    1 point
  14. You have more than the event->return available to you in the hook - you have $event->object, which is the inputfield. $this->addHookAfter('InputfieldFile::renderItem', function($event) { $inputfield = $event->object; $files = $inputfield->value; // find file you want in $files });
    1 point
  15. Ok ! Then I found a simple and evident solution : I associated my template "special-page" on root 'Home' in Processwire back-office. It worked fine ! Thanks for your help and your pretty goode module
    1 point
  16. In my opinion, three separated fields would be the best solution. If you are not sure, wether your users will enter the right values into an field, you can always point them into the right direction using the description or notes for each field. Even though it might not be the most comfortable way, if used you can do all sorts of sorting and filtering in the front end with this data. Another approach @adrian was pointing to, is using a hook to save the extra fields combined in the map marker field.
    1 point
  17. I'm after InputfieldFile::renderItem where $event->return is markup. I've updated the function so it works for Pageimage and Pagefile: /** * Returns Pageimage or Pagefile object from file path * getPageimageOrPagefileFromPath('/site/assets/files/1234/file.jpg'); // returns either Pageimage or Pagefile object * getPageimageOrPagefileFromPath('/site/assets/files/1234/file.txt'); // returns Pagefile object * getPageimageOrPagefileFromPath('/site/assets/files/1234/none.txt'); // returns null * * @param straing $filename full path to the file eg. /site/assets/files/1234/file.jpg * @param Page|null $page if null, page will be contructed based on id present in the file path * @return Pagefile|Pageimage|null * */ function getPageimageOrPagefileFromPath($filename, $page = null) { if(is_null($page)) { $id = (int) explode('/', str_replace(wire('config')->urls->files, '', $filename))[0]; $page = wire('pages')->get($id); } if(!$page->id) return null; // throw new WireException('Invalid page id'); $basename = basename($filename); // get file field types, that includes image file type $field = new Field(); $field->type = wire('modules')->get('FieldtypeFile'); $fieldtypes = $field->type->getCompatibleFieldtypes($field)->getItems(); $selector = 'type=' . implode('|', array_keys($fieldtypes)); //foreach(wire('fields')->find($selector) as $field) { foreach($page->fields->find($selector) as $field) { $files = $page->getUnformatted($field->name); if($files) { $file = $files[$basename]; if($file) return $file; // match found, return Pagefile or Pageimage //check for image variations foreach($files as $file) { //if(method_exists($file, "getVariations")) { if($file instanceof Pageimage) { $variation = $file->getVariations()->get($basename); if($variation) return $variation; // match found, return Pageimage } } } } return null; // no match }
    1 point
  18. How is that you have a path to a file (the $filename argument in your function) that exists in a field on a page without any information about the page and field? Where does $filename come from?
    1 point
  19. Strange, that it didn't work for you. Be sure, that your developer tools are open, when refreshing the site. But if the others solutions work for you, than that is fine too.
    1 point
  20. @Robin S you're my hero again for this module! Seriously every time I think of something I need in PW you're already on it.
    1 point
  21. @Pravin Hi Pravin, it's been a while since i played with processwire... My setup was a little bit confusing. I ended up having three files. As i look trough my files. When you have managed the upload, you probably have some sort of files array. In my files i used some part of wire upload i think. // RC: create temp path if it isn't there already if(!is_dir($upload_path)) { if(!wireMkdir($upload_path)) throw new WireException("No upload path!"); } // setup new wire upload $u = new WireUpload('file'); $u->setMaxFiles($max_files); $u->setMaxFileSize($max_upload_size); $u->setOverwrite($overwrite); $u->setDestinationPath($upload_path); $u->setValidExtensions($file_extensions); // start the upload of the files $files = $u->execute(); Now i had my "files" array. Then i put my xml code in. // create XML files for switch // remove extension from files $withoutExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $files); foreach($withoutExt as $withoutExt_string) { $doc = new DOMDocument('1.0'); // we want a nice output $doc->formatOutput = true; $root = $doc->createElement('phpemail'); $root = $doc->appendChild($root); $email = $doc->createElement('email'); $email = $root->appendChild($email); $text = $doc->createTextNode($newemail); $text = $email->appendChild($text); $doc->save($upload_path . $withoutExt_string . ".xml"); } hope it helps.
    1 point
  22. https://seld.be/notes/php-versions-stats-2016-2-edition Data comes from packagist. New versions are being adopted faster and faster. Something to consider, when thinking of PW minimum requirements. PW is still saying 5.3.8 is the minimum. May 2016 All versions Grouped PHP 5.5.9 11.87% PHP 5.6 39.67% PHP 7.0.6 10.39% PHP 5.5 29.56% PHP 5.6.20 8.41% PHP 7.0 20.24% PHP 5.6.21 7.69% PHP 5.4 7.64% PHP 5.6.19 4.71% PHP 5.3 2.43% November 2016 All versions Grouped PHP 7.0.12 8.58% PHP 5.6 37.46% PHP 5.5.9 8.25% PHP 7.0 35.01% PHP 7.0.11 7.62% PHP 5.5 18.93% PHP 7.0.8 6.92% PHP 5.4 5.40% PHP 5.6.26 6.12% PHP 5.3 1.60% PHP 5.6.27 4.49% PHP 7.1 1.36%
    1 point
  23. As we're now using composer this might become a bit more relevant, but this is really missing out all those systems, where composer isn't being run. There are certainly a lot of servers / hosters out there which are fine with running old version of php for those wordpress and other clicky install cms's. I'd certainly like to see ProcessWire up the requirements in php version, especially as everything below 5.6 is EOL, but Ryan seems to like keeping ProcessWire as compatible, even to shitty hosters, as possible.
    1 point
  24. COMPOSER ELLIOTT CARTER (December 11, 1908 - November 5, 2012) is internationally recognized as one of the most influential American voices in classical music, and a leading figure of modernism in the 20th and 21st centuries. https://www.elliottcarter.com/ This site was launched some months ago, and was one of the larger projects I completed so far. It took about 4 month to build. (PW 2.7.3) This was the first project I used the wireRenderFile() pattern on, and it consequently allowed me to reuse a lot of output code, as well as do a lot of markup/object caching with wirecache. The site uses DataTables for all of the major listing pages, Works, Discography and Events, allowing users to filter and search with no page reload. This probably has the most advanced caching setup that I've done so far, and one example of how it works is on the discography page: https://www.elliottcarter.com/discography/ That page has to hold all 264 albums (json object which is rendered by dataTables), and each album takes a bit of processing to render (formatting of works, artists etc.). The json for each album's list view is wirecached individually and is generated on visits to the individual album pages, so that they never get generated all at once when visiting the discography page. The complete json object containing all of the albums is also wirecached, then the final page is pro-cached. The album covers are lazy loaded so as to not affect page size or load speed. The selects on the left are also all wirecached as page or regular arrays. This results in a 1.6s page load time and a page size of 1.12 MB. Without the data being wirecached the load time is around 9 seconds to generate the page, probably longer if it had to regenerate all 264 albums, but the album info never changes, so they are permanently cached unless someone edits one. Also should note that since there is so much use of wirecache, @Soma's Clear Cache Admin was pretty much indispensable for managing all of the caches. Other features of the site include extensive use of Schema.org microdata, an events submission system, and a lot of custom stuff in the admin for managing the content, such as automated fetching of album covers from Amazon, converting formbuilder submissions into events, a custom admin dashboard etc.. There are probably 60 modules in use overall, but these in particular saved the day: MenuBuilder AdminCustomFiles AdminPageFieldEditLinks All the Selectize modules URL checker PrevNextTabs WireMailMailgun SetupPageName Changelog AdminCustomPages Twitter Feed Social Share Buttons RSS Enhanced Chosen Select Runtime Markup Batch Child Editor Tracy Debugger As well as all of the pro modules (ProFields, FormBuilder, ListerPro, and ProCache). More info, screen shots etc will be gradually posted here...
    1 point
  25. All sorted - I published it which actually requires: More > Move https://en.wikipedia.org/wiki/ProcessWire
    1 point
  26. Hey darkmesaia! (it is so enjoyable how you can welcome people with such names without a doubt on Internets ) Welcome to the forums! If you need a customizable CMS - ProcessWire is certainly one of the best. Go ahead and try it. You can change almost everything on the frontend and a lot in the admin area. Give it a try. ProcessWire is not based on any of the general purpose php frameworks. But it has a set of features built in you would expect from a framework. And you can always extend with community modules or composer packages. I would say ProcessWire would save quite some time comparing to building a CMS from scratch. Feel free to ask further. Or just dive in and try building something with the help of the tutorials.
    1 point
  27. If you just need the url for a redirect this does work: $session->redirect('.');
    1 point
  28. what (default) settings have you used for upscaling and cropping when called $img->size(200,100) ? (ich frage hier auch noch mal nach falls Du die Email nicht siehst. skype nutze / habe ich nicht) EDIT 1: I got the mail EDIT 2: issue seems to be solved! (PR will follow)
    1 point
×
×
  • Create New...