Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/03/2014 in all areas

  1. Some examples from some of my modules - only because I quickly know where I have used these things I'll link to the hook, so obviously also view the called function as well. New tab https://github.com/adrianbj/ProcessRedirectIds/blob/master/ProcessRedirectIds.module#L104 $this->addHookAfter('ProcessPageEdit::buildForm', $this, 'addTab'); Add content to existing tab https://github.com/adrianbj/BatchChildEditor/blob/master/BatchChildEditor.module#L100 $this->addHookAfter('ProcessPageEdit::buildFormChildren', $this, 'addChildTabContent'); Obviously with this, "buildFormChildren" could be replaced with buildFormSettings etc. Hope that helps.
    5 points
  2. div class='breadcrumbs'><!-- breadcrumbs --> <?php // breadcrumbs are the current page's parents foreach($page->parents() as $item) { //skip SideBarPages using id of the page. //You can also use $item->id=='1234' $item->title=='titleOfSideBarPages, $item->name, etc //using the ID, though less readable, is more foolproof if ($item=='1234') continue; echo "<span><a href='$item->url'>$item->title</a></span> "; } // optionally output the current page as the last item echo "<span>$page->title</span> "; ?> </div><!-- end breadcrumbs -->
    4 points
  3. I recall this conversation here: https://processwire.com/talk/topic/1176-hiding-uneditable-pages-from-users/ Scroll down for the solution - See posts #7, 13-30
    3 points
  4. You could create a module based on LazyCron by Ryan and combine it with my E-Mail-Verfication-Module which checks also availability of mailhost. Here is a function to check availability of an url. function check($str, $needle) { return (strpos($str, $needle) !== false); } function validate($url) { $header = @get_headers($url); return (isset($header) && count($header) > 0 && check($header[0], "200")); }
    3 points
  5. Congrats Kongondo. Looks like your link has solved this for me. I'll just take a few minutes to verify and hopefully post a full solution later. Edited to add: Yes, the solution was found in Soma's post here. He links to a module he posted to gist and that works great for me.
    2 points
  6. If one want to exclude all hidden pages one may use: if ($item->isHidden()) continue;
    2 points
  7. Yesterday I looked at the HTML output of a PW website of mine and thought it looked kind of messed up. It wasn't because the code was bad or I used the wrong tags. It also wasn't because I somehow forgot to close open tags (w3c validation went fine). No, it only was because the HTML output wasn't well formatted. I think this is a pretty common "problem" when using PHP to generate your HTML code instead of creating static HTML pages. To solve my "problem" I searched a bit and stumbled upon https://github.com/gajus/dindent. The idea behind this remarkable little piece of software is imho great: In opposite to HTML purifier or tidy Dindent doesn't manipulate your HTML code in a sense that it will behave differently. It doesn't close unclosed HTML tags or something like that. No, Dindent only changes the format of the HTML output to make it more readable and appear cleaner. So, as a developer, you are still responsible for creating proper HTML code! So I decided to create a simple little ProcessWire module that hooks into the render-method and applies the magic provided by Dindent. That's all! But I really think it can make a difference in the presentation of your website for everyone that looks a bit deeper into your project and therefore looks at the HTML code your website provides. Beware: Of course the whole beautifying process is not free. It costs some time, so it works best together with a caching mechanisms (favourably the fantastic ProcessWire ProCache)! What do you think? DIndent_v1.0.0.zip
    2 points
  8. Ok, I have committed a new version that supports protection via the API. You can now do: // all optional, except "page_protected", which must be set to true/false // if setting it to false, the other options are not relevant $options = array( "page_protected" => true, "children_protected" => true, "allowed_roles" => array("role1", "role2"), "message_override" => "My custom login message", "prohibited_message" => "My custom prohibited access message" ); $page->protect($options); Let me know if you have any problems. EDIT: I am wondering if in your case dedicated code might be a better solution. This module stores the protection info in the module's data DB field. While this works great because there is no need for special fields to be added to the templates of a pages to be protected, I am worried you might come across some scaling issues if you have thousands or potentially millions of users, all wanting to protect various pages. I have no idea on the scale of your social network, but this is definitely something to consider.
    2 points
  9. I would be willing to contribute to the project within the next 3 months because it seems like I will have plenty of free time during this period. The other question is if you're willing to let others work on your project especially semi-experienced php developers like me.
    2 points
  10. To get a page by index number from a PageArray is easy: /* returns a page object */ $pagebyindex = $myparentpage->children->eq(integer $num); Now I needed a function which returns the Index of the page from the siblings. It took me a while to figure this out, and I like to share this here: /* returns an integer */ $indexbypage = $myparentpage->children->getItemKey($page); // or $indexbypage = $page->siblings->getItemKey($page); Found this information in http://cheatsheet.processwire.com/ under section PageArray/WireArray and here: http://processwire.com/apigen/ To get complete information about API this page is your (and my) friend. Have a nice day
    2 points
  11. No, no. Apache has nothing to do with this module. The module only identifies the page name, does some path voodoo and that's it. No further server side configuration needed. Your mistake is that you added several different domain names in the module's configuration. So basically it has to be configured like that: - Homepage -- sub page 1 -- sub page 2 [...] -- sub site (with page name "hortonsshortuns.com") --- sub site sub page 1 --- sub site sub page 2 --- sub site sub page 3 [...] And in your module's config you only define "hortonsshortuns.com" as another domain. The www stuff should be configured with htaccess, but never ever put several domain variations in the module's config. This has to go wrong.
    2 points
  12. Is the use of a dedicated folder important? Add an image field to the homepage and then output a random image from those images in the newly created field When the field name with mutliple images is random_photos <? echo $page->random_photos->getRandom()->url;?> This will return a random photo from the images field every time you reload the page. EDIT: To make it prettier: <?php $random_image = $page->random_photos->getRandom();?> <img src="<?php echo $random_image->url;?>" alt="<?php echo $random_image->description;?>"/>
    2 points
  13. First off I would have never guessed that there's a gallery link hidden in that picture frame icon. I clicked the images to no success (hm what's supposed to be here?) Ok just a glance at html <!DOCTYPE HTML> <!-- copyright 2014 OwlTree Web Solutions Ltd --> <html lang="en"> Not sure but some long year experience says this comment could cause issues. Definately if it would be at top (for IE) Aand we have a js error $ undefined., which 99.999% is jquery not included/loaded before a jquery script using $. <script type="text/javascript" src="/carman/site/templates/scripts/main.js"></script> <!-- Pretty Photo CSS and scripts --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript" src="/carman/site/templates/scripts/jquery.easing.js"></script> <script src="/carman/site/templates/scripts/jquery.prettyPhoto.js" type="text/javascript"></script> <link rel="stylesheet" href="/carman/site/templates/styles/prettyPhoto.css" type="text/css" media="screen" /> Even if main.js seems empty to you there's a $(document) and it's included before jquery core. Loading jquery core like this <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> What do you do if server google isn't available. There should be a fallback like https://github.com/h5bp/html5-boilerplate/blob/master/dist/index.html#L25 Finally this is the gallery markup <a href='/carman/site/assets/files/1036/con11.jpg' class='gallery' data-rel='prettyPhoto[pp_gal]'><img src='/carman/site/templates/images/gallery.png' alt='Conservatories Gallery' /></a> <a href='/carman/site/assets/files/1036/con12.jpg' class='gallery' data-rel='prettyPhoto[pp_gal]'> </a> <a href='/carman/site/assets/files/1036/con3.jpg' class='gallery' data-rel='prettyPhoto[pp_gal]'> </a> <a href='/carman/site/assets/files/1036/con4.jpg' class='gallery' data-rel='prettyPhoto[pp_gal]'> </a> <a href='/carman/site/assets/files/1036/con5.jpg' class='gallery' data-rel='prettyPhoto[pp_gal]'> </a> <a href='/carman/site/assets/files/1036/con6.jpg' class='gallery' data-rel='prettyPhoto[pp_gal]'> </a> <a href='/carman/site/assets/files/1036/con7.jpg' class='gallery' data-rel='prettyPhoto[pp_gal]'> </a> <a href='/carman/site/assets/files/1036/con8.jpg' class='gallery' data-rel='prettyPhoto[pp_gal]'> </a> <a href='/carman/site/assets/files/1036/con9.jpg' class='gallery' data-rel='prettyPhoto[pp_gal]'> </a> <a href='/carman/site/assets/files/1036/con10.jpg' class='gallery' data-rel='prettyPhoto[pp_gal]'> </a> Possibly the use of 'attr' instead of "attr", you'll laugh but I got caught by it once, but don't remember what case it was. I don't think so here is the case. In my Firefox it loads the gallery but the container is positioned far far down. Only after scrolling some it shows up. Offset is inline calculated from top and seems wrong. I removed you CSS "height: 100%" from <body> and <html> and it works fine.
    2 points
  14. Hi All, I have spent a decent amount of time over the last two days (starting yesterday on American Thanksgiving) rebuilding my main personal business photo site with Processwire. For now this project is still being developed on a local install of MAMP. I did not wake up yesterday with the intension of starting this project - but I just went for it... Going back a few months: I discovered Processwire by accident. I was not really looking for a new CMS to replace my weapon of choice, namely MODx. Processwire seemed intriguing, but to be honest I had serious reservations in the beginning. After some initial tire kicking my conclusion was "this looks like a really interesting alternative, but this system is for advanced developer geeks with skills, it might never be the playground for you..." Initially my commitment to Processwire was an awkward stop and go experience. But I stuck with it. I asked some basic questions that just screamed "newbie alert" but the constructive and helpful responses were rewarding. I began to take notice and found that overall the Processwire Forum was simply first class. I know my way around markup HTML, CSS and pushing pixels around. But I can't write scripting code like PHP to save my life. I thought this was going to be a deal breaker - but I stuck with it. Fast forward to today: I am amazed at how much I got done! I am taking an existing MODx site and converting/improving all the dynamic elements from MODx to Processwire. Along the way I am streamlining the markup, the CSS, the logic, while adding more efficient Processwire building blocks than I thought possible, all without needing to fire off "help me" requests to the Processwire forum. I am also improving my CSS skills and I am even beginning to feel less intimated with working with PHP code. I guess you could call this the Processwire "aha" moment. It just feels good! I am really enjoying working with this system. There is so much in the Processwire arena that is still a mirage in the sand, but I think that with time I will add more and more knowledge. I guess that is it. I really appreciate the help and encouragement from you all... Cheers, Max
    2 points
  15. This module allows you and your site editors to protect a page (and optionally its children, grandchildren etc) from guest access directly from the page's Settings tab. You can also limit access to certain roles. http://modules.processwire.com/modules/page-protector/ https://github.com/adrianbj/PageProtector It makes it very easy for editors to set up various password protected areas on their site, or to simply protect a new page or section while they are still working on it. Ability for your site editors to control the user access to pages directly from Settings tab of each page Include whether to protect all children of this page or not Optionally allow access to only specified roles Option to protect all hidden pages (and optionally their children) Ability to change the message on the login page to make it specific to this page Option to have login form and prohibited message injected into a custom template Access to the "Protect this Page" settings panel is controlled by the "page-edit-protected" permission Table in the module config settings that lists the details all of the protected pages Shortcut to protect entire site with one click In addition to the admin interface, you can also set protection settings via the API: // all optional, except "page_protected", which must be set to true/false // if setting it to false, the other options are not relevant $options = array( "page_protected" => true, "children_protected" => true, "allowed_roles" => array("role1", "role2"), "message_override" => "My custom login message", "prohibited_message" => "My custom prohibited access message" ); $page->protect($options); As alway, I would love any feedback / suggestions for improvements. Hope you find it useful! Page Protection Settings (settings tab for each page) Module Config Settings
    1 point
  16. Hello! About the same time Hari KT asked about "Remember Me" functionality, I identified this as a feature I wanted to implement in some sites under development. Having done this twice before (in CodeIgniter) and based on previous research, I decided to build a ProcessWire module to provide this feature. So far, I have developed and tested this on ProcessWire 2.3. I would welcome any feedback, comments, suggestions and problems from people who are keen to use this. To re-iterate the readme, this module allows users to remain logged in across browser sessions. The module can operate in two ways:Automatically. No code changes, but users do not have a choice. Manually. The module must be called from a site's custom code. Options can be changed in the module configuration page. Enable fingerprinting (IP address and User Agent) as an additional security check. Limit the persistent login functionality by role. Set the name and age of the cookie. Sets an identifier in the session when a user is logged in via a persistent login cookie. This should be used to control access to sensitive information and actions within a site's custom code. Clears login tokens when a potential theft has been identified. Updated: LoginPersist on GitHub
    1 point
  17. Introducing PVC PvcCore: https://github.com/oliverwehn/PvcCore/ PvcRendererTwig: https://github.com/oliverwehn/PvcRendererTwig/ (coming soon) PvcGenerator: https://github.com/oliverwehn/PvcGenerator/ (coming soon) Each time I’ve built a ProcessWire page I’ve struggled with organizing (and separating) code, markup and stuff. Playing around with frameworks (backend as well as frontend) like Rails, Ember and stuff I really liked having a given structure, knowing where to put what piece of code. Therefor I started working on a MVCish way to deal with templates in PW that considers the $page object kind of the data/model layer and adds View and Controller upon it. First by just catching everything via a small processor file added to all PW templates as altFilename. I’ve digged a bit deeper since then and hooked into the native rendering process, have been refactoring my code base more than a dozen times. Now I got a first version that seem to work and I’d love some of you guys to try it out! PVC (instead of MVC) stands for Page-View-Controller, as it considers PW’s $page var the model/data layer. I’m still working on the README.md on GitHub to document the basics. So have a look for more detailed infos there. I’ll give you a short overview here: Code separation: PVC introduces views and controllers to your PW templates as well as multiple action templates. Controllers, as most of you already know, keep all the business logic. Controllers execute actions wired to routes (urlSegment patterns). Even routes with dynamic segements (e.g. /edit/:id/) can be defined and assigned to an action, providing input through $this->input->route. Values can be set on the controller to be accessable in your templates later on. It’s also possible to set dynamic values as closures to be calculated (e.g. using field values of the current page) on render. Also controllers allow you to set layouts, styles and scripts to be available in your layout or template. Logic can be shared through inheritance between controllers. Views introduce view helpers. Helpers are functions that are made available to you (only) within your template context. There are predefined ones like embed(), snippet(), styles() or scripts(). But you can implement your own helpers easily and share them among your view classes through inheritance. Action templates contain the actual markup. Every action defined in a controller uses its own template. So the same page can display content accordingly to the action that was addressed via urlSegments/route. Within templates you can access all field values and values set on your controller like globals (e.g. <?=$title?>). Modular renderers: PVC implements rendering through separate renderer modules. PvcCore comes with PvcRendererNative that gives you template syntax the good ol’ PW/PHP way. A Twig renderer is in the making. And maybe you want to build your own renderer for the template syntax of your choice? I consider the module an early Beta version. So make sure to try it within a save environment! Would love to get some feedback (and error reports). I’m no professional developer, so code quality may suck here and there. So I’m glad for inputs on that, too. Also there is some old stuff in there yet, I still have to get rid of.
    1 point
  18. A starting point module to use angularjs in our templates in an easy manner.
    1 point
  19. Ha! I didn't notice that . Well I hope I said something useful
    1 point
  20. Sorry, I think I misunderstood how to use this. Thank you so much for your help Horst!
    1 point
  21. I'm not sure if I understand you right. But if you cannot add the hook on template layer, you need to create a module: <?php class SizeToCloud extends WireData implements Module { static public function getModuleInfo() { return array( 'title' => 'Size To Cloud', 'summary' => __('This module handles relations between pageimages and S3 cloud', __FILE__), 'version' => '0.0.1', 'author' => '', 'href' => '', 'singular' => true, 'autoload' => true, // 'requires' => array('PHP>=5.3.8', 'ProcessWire>=2.5.0') ); } public function init() { $this->addHook('Pageimage::size2cloud', $this, 'size2cloud'); } public function size2cloud($event) { $image = $event->object; // the event object is a pageimage $width = $event->arguments(0); // first argument to pageimage::size is the width $height = $event->arguments(1); // yes, second is height $options = is_array($event->arguments(2)) ? $event->arguments(2) : array(); // and optional an options array can be passedd // now do the manipulation and catch the resulting variation object $imageVariation = $image->size($width, $height, $options); // get the filename for your cloud stuff $filename = $imageVariation->filename; // do your stuff here ... // // return the variation pageimage object // return $imageVariation; // what do you need to return here? } } This example code should be saved as a file named SizeToCloud.module. It should be cpoied under site/modules/SizeToCloud/SizeToCloud.module Then refresh your modules section find it under new and install it. For more on Modules refer to the docs and to the HelloWorld.module what is a super good example module with all commented.
    1 point
  22. <nav class="top-bar" data-topbar> <section class="top-bar-section"> <ul class="right"> <li class="divider"></li> <?php $treeMenu = $modules->get("MarkupSimpleNavigation"); // load the module $options = array( 'has_children_class' => 'has-dropdown' ); echo $treeMenu->render($options); // render default menu ?> </li> </ul> </section> </nav> The pattern is very easy. The above example will attach the class "has-dropdown" to every list item that has a submenu. Try to understand the Readme by comparing it to my example and you will understand quickly. Edit: Misspelling corrected
    1 point
  23. Foundation requires its classes (e.g. "has-dropdown") in order to work fine. Please see the Readme section of Somas module to learn how to apply classes to the elements of the menu.
    1 point
  24. There are at least three foundation profiles on the forum - this is mine. Out of date so you might need to mess with it if any of the classes has changed https://github.com/jsanglier/foundwire/blob/master/templates/includes/navigation.inc (from an original code by Soma) EDIT: You can probably also use Soma's markup navigation module. Probably a better solution
    1 point
  25. Ah, ok, no I misunderstood you. You're right with the namespaces that were introduced with PHP 5.3.0 Anyway, I can't really say which PW version is required for my module, because I've only tested it with PW 2.5 I'm pretty sure thought it would also work with PW 2.2+ (and below was no "requires"-field I think). Right now I'm tending to let the module only require the PHP version and not the PW version so nobody is restricted unnecessarily. Is there somewhere a documentation that points out which feature/hooks/methods/etc. were added at which PW version?
    1 point
  26. What do you want to do? You want add / copy / submit all final files of a resize manipulation (one of width, height, size) additionally to a cloud? This can be done by simply get the filename after a manipulation. For this you may add your own wrapper to the pageimage functions. There is also no need to change width or height to size, because width and height are only wrappers for size. Finally size is called for all pageimage manipulations. You can add a simple hook to pageimage like this: wire()->addHook("Pageimage::size2cloud", null, function($event) { $image = $event->object; // the event object is a pageimage $width = $event->arguments(0); // first argument to pageimage::size is the width $height = $event->arguments(1); // yes, second is height $options = is_array($event->arguments(2)) ? $event->arguments(2) : array(); // and optional an options array can be passedd // now do the manipulation and catch the resulting variation object $imageVariation = $image->size($width, $height, $options); // get the filename for your cloud stuff $filename = $imageVariation->filename; // do your stuff here ... // // return the variation pageimage object // return $imageVariation; // what do you need to return here? }); // in your templates now you call the images like $image->size2cloud( 200, 0); // or $image->size2cloud( 200, 200, array("crop"=>false, "quality"=>70, "sharpening"=>medium)); // or $image->size2cloud( 0, 200); This can be set into a template file, e.g. if you have something like a inifile that is included into all template files. Or, if do not use this technique, you build a module from the function.
    1 point
  27. yes - this is a texbook page table scenario...
    1 point
  28. Glad you sorted it! However, RE PHP and the use of double versus single quotes, the below is not true. You can use either quotes with certain caveats. More info here: http://php.net/manual/en/language.types.string.php http://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php
    1 point
  29. Thanks to everybody for your help. I have now managed to resolve the issues following the comments from Soma. The problem basically came down to 2 things: Bad placement of script tags in the <head> of the site. i had the min.js and analytics.js appearing before jquery had actually loaded but I hadn't spotted it. (strange how some browsers accept it and others don't) The css height: 100% from <body> and <html> Soma - Thanks for the solutions and your point about jquery fallback, it wasn't something I'd considered but it makes sense. I've now added this into the extra line into the <head> and I'll make sure I do it for all future sites as well. I've also took note of your comment re the picture frame icon. It's a good point and I'll make it more obvious that it is an actual gallery link. With reference to the use of 'attr' instead of "attr", this is not really an option as PHP see's " as closing the statement so it is necessary to keep it at ' for any attribute. ​It's now working on all the browsers on Windows, OSx and Linux, as well as iOS and Android, so all is good. Mike Anthony - I'll check out Magnific at some point, it's always useful to have alternative options.
    1 point
  30. Hhm, it wasn't clear to me that you have encountered differences between Pageimages derived from Pageimage or derived from PiM. (or I may have overlooked it in all that examples) I think it would have avoided some confusion if you just have asked / told that the objects behave different, without (partly wrong) code and lots of error messages. You are also speaking about filenames generated with .0x0 in its name.?! Pageimage::size generates the filenames before any manipulatiuon through ImageSizer and only according the passed values for width and height. So, at that point you may check what values you are passing to the functions. ------ But lets focus on that objects thing: I will try to replicate and compare that. Just to clarify a few things: You have checked that after your PiM call a Pageimage Object is returned? Have you tried it with a PiM that does other manipulations, maybe just pimLoad()->pimSave(). Does it behave the same or is it different? Pim generates the PageimageObjects this way: https://github.com/horst-n/PageImageManipulator/blob/master/ImageManipulator.class.php#L751 It looks the same like Pageimage::size does it: https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/core/Pageimage.php#L316 So, we need to compare the objects, first try with simple objects that only should differ in the name: $size = $image->size($image->width, $image->height); $pim = $image->pimLoad('test')->pimSave(); And then with a manipulated one from your example. ------ Ah, ok! Sorry for remember me wrong!
    1 point
  31. These are similarly useful WireArray: http://processwire.com/api/arrays/ PageArray: http://processwire.com/api/arrays/page/
    1 point
  32. maybe a part could be done by restricting children - parent relation via family settings? Template for parent that only allow a single Template for children. That way, when adding a child, it has the right Template and the right position. Only thing left is the population of your field.
    1 point
  33. @Ivan, Part of my stock toolkit when building sites is a "save action". It is a simple way to run some action when the user saves; they select the save action, and click save, and the action runs. It usually hooks into SaveReady. It could be anything from calculating/validating/correcting/filling in blank fields to things like deleting children, renaming assets (images, files) etc.. I usually use a special select field for this, but you could use a checkbox. If I needed to create the functionality you are describing right at this moment, i would make the save action a checkbox and then have next to it After save: Create new classified Item; your module code would then simply create a new page under the specified parent and redirect the user to that edit page...
    1 point
  34. An easy way if you wanna build a big list would be to just make a little array with all the rules and use that to filter. $excludeArray = array( "include=hidden", "parent!=2", "id!=1009", "parent!=1047", "id!=27", "id!=7", "parent!=7", "id!=1047", "id!=4945", "template!=items", "template!=antique-items", "template!=publication", "template!=publication_type", "template!=publication_section", "template!=404", "id!=2947", "path!=/processwire/" ); $exclude = implode(",",$excludeArray); $children = $page->children($exclude);
    1 point
  35. Adrian, great, thanks! This is exactly what i needed. I'm going to test it deeper tomorrow. Guys, i've never found a community so caring, i wish i could be more helpful in the future.
    1 point
  36. Hi invamped. Welcome to PW and the forums. I don't know much about AngularJS but maybe this module can help? https://processwire.com/talk/topic/8420-processwire-angularjs/
    1 point
  37. I am sure others would be willing to contribute to this project/module if you released it and would be happy with that dependent in which form you want to release it(closed or open project). Not sure if you know but there was a discussion here about putting together an active “Shop Development Group” if you would be open to something like that. If you release early bird, I promise not to ask support from you.
    1 point
  38. No worries guys, sorry I haven't keep you updated. It's been busy here with other things, so no new progress on this. I think it will take winter (or next summer...) holidays for me to get back to this. Maybe I release early bird release of what I have now... I have been hesitating with that because I know I can't provide any real support.
    1 point
  39. Module In Progress... working on an Inputfield which will allow the updating of the select description (for contextual description of the actual selected item) based on the selected option. This module is/was mostly written by netcarver, so i'm just getting the details together and some jquery for this to work... https://processwire.com/talk/topic/419-extending-inputfields/?p=76823 i'm thinking that the module title should probably be more specific?, like InputfieldSelectDataDescription... in case there were other 'extended' interpretations...? module so far: <?php class InputfieldSelectExtended extends InputfieldSelect { public static function getModuleInfo() { return array( 'title' => __('Select Extended', __FILE__), 'version' => 1, 'summary' => __('Selection with extended attributes. An enhancement to select', __FILE__), 'permanent' => false, ); } /** * inputfield is loaded */ public function init() { // append script needed for the inputfield $this->config->scripts->add($this->config->urls->InputfieldSelectExtended . 'InputfieldSelectExtended.js'); } /** * Adds an option with extended attributes that allow mutually exclusive groups. */ public function addOption($value, $label = null, array $attributes = null) { if ( is_null($value) || (is_string($value) && !strlen($value)) ) { return $this; } if (null === $attributes) { $attributes = array(); } $extra_atts = $this->extendAttributes($value, $label); $attributes = array_merge($attributes, $extra_atts); return parent::addOption($value, $label, $attributes); } /** * Hook this and return an array with whatever extended attributes you need. * */ public function ___extendAttributes($id, $value) { $atts = array(); $page = wire()->pages->get($id); $atts['data-description'] = $page->data_description; return $atts; } } the js, so far - works, but doesn't account for multiple selects yet. InputfieldSelectExtended/InputfieldSelectExtended.js $(document).ready(function() { var $default = $('.InputfieldSelectExtended').prev('p.description').html(); $('.InputfieldSelectExtended select').change(function(){ var $selected = $(this).find(':selected'); var $description = $('.InputfieldSelectExtended').prev('p.description'); if($selected.data('description') == null ) $($description).html($default); $($description).html($selected.data('description')); }).trigger('change'); }); once installed you would need to add this inputfield to the list; then select the inputfield on your page field your selectable pages would need a data_description field. here is the result, before option selected: after select: i guess once i get the module more advanced, there would be a way to get some of these things automatically setup.. also - for this to work, you need to set a description for the page select field, so there is something to replace...
    1 point
  40. Thanks alanfluff for your post: Solved with 777 on the sessions folder and all contents. Oh it feels good to get Apache off the war path.
    1 point
  41. I am sure lots of very cool things could be done, all of which will require a little more than the 5 mins of planning and 20 mins of coding I put into this one Here is a revised version (with a new name) with about an extra 15 mins of coding that adds support for batch adding/removing of fields from templates. I think I might actually make use of this version quite a bit. EDIT: I don't think "Template Setup Batcher" is the right name - not really about setting up templates from scratch. Oh well - maybe change again if a newer version ever happens ProcessTemplateSetupBatcher.module
    1 point
  42. I suggest that whatever you do you stay away from any fixed scaffolding framework. The point of ProcessWire is that people can use whatever layout structure they want. For instance, many like Bootstrap and Foundation as complete solutions, but many others find them large and cumbersome and too limited. If you have a large framework with lots of JS and CSS and then people want different JS for different slideshows or product display and so on, you can end up with an inflated beast. So, I would suggest you stick to the functionality in a very agnostic way and make sure it is done in such a way that people can create the template files it as they wish.
    1 point
  43. I think we would have to put together kind of an active “Shop Development Group”. I love coding, but I’m definitely not that much a developer to lift a task like this. But I have some ideas on how to structure the modules to achieve a maximum of flexibility regarding how to layout your shop within the page tree. Splitting the challenges is small packages may be the key to success here. I’ll try to sketch my ideas. Could be a point to start. Maybe, when this thing gains some momentum, we could create an own github account for this where all shop modules are bundled and specific discussions on functionality can happen in the issues section. Who would be interested in contributing to a project like this?
    1 point
  44. I have made a module for you (all). I have had allready a routine that iterates through all pages and clears all imagevariations. But this only can be safely used if you have not used images in RTE's from the same page. If you have done so, those cannot be identified and gets deleted too. So please double check that you do not use Pageimages in your RTE fields before running this module. To run it you have to install it, go to its configscreen and check the box to run it. Also there is a second box, always checked by default, that let the script run in testmode. In testmode it doesn't delete the variations but list all found pages and the images count. So, if you really want to delte all ImageVariations sitewide, tipp the box to run the script, untipp the box to run it in testmode and press the submit button. PageimageRemoveVariations.zip EDIT: better use this enhanced module version from @tpr, with configuration for excluding imagefields: enhanced version!
    1 point
  45. You could definitely use PW to build Facebook (feature wise). There is absolutely no reason to worry about being biggest and most active website of all, before you haven't written a line of code for the project. I have build websites for over 15 years (8 of them professionally) and there have been very few scalability issues. But oh boy I have worried. The very same question that epreston asked: does it scale? After these 15 years I am pretty sure it is much harder to build service that will be so popular that actually needs to be scaled - than the actual scaling.
    1 point
  46. My solution, which works nicely: I put the following code on the top of my template. (example for French as default, German and English) $date_lang = array(); switch ($user->language->name) { case 'en': setlocale(LC_ALL, 'en_GB'); $date_lang[0] = "%A %B %eth %Y at %I:%M %p"; $date_lang[1] = "%B %eth %Y"; $date_lang[2] = "%I:%M %p"; $date_lang[3] = "%A"; break; case 'fr': setlocale(LC_ALL, 'fr_FR'); $date_lang[0] = "%A %e %B %Y à %kh%M"; $date_lang[1] = "%e %B %Y"; $date_lang[2] = "%kh%M"; $date_lang[3] = "%A"; break; case 'de': setlocale(LC_ALL, 'de_DE'); $date_lang[0] = "%A, den %e. %B %Y um %k.%Mh"; $date_lang[1] = "%e. %B %Y"; $date_lang[2] = "%k.%Mh"; $date_lang[3] = "%A"; break; default: setlocale(LC_ALL, 'fr_FR'); $date_lang[0] = "%A %e %B %Y à %kh%M"; $date_lang[1] = "%e %B %Y"; $date_lang[2] = "%kh%M"; $date_lang[3] = "%A"; } Then I created a page field, where I store a date unformatted (go to setup->fields->mydatefield->details-> date output format ->"None"). getUnformatted() is only needed, if the date is stored formatted. Finally I can insert the date like echo strftime($date_lang[0], $mydatefield); /* output(de): Freitag, den 11. Oktober 2013 um 12.52h * output(fr): Vendredi 11 octobre 2013 à 12h46 * output(en): Friday October 11th 2013 at 12:46 pm */ echo strftime($date_lang[1], $mydatefield); /* output(de): 11. Oktober 2013 * output(fr): 11 octobre 2013 * output(en): October 11th 2013 */ echo strftime($date_lang[2], $mydatefield); /* output(de): 12.52h * output(fr): 12h52 * output(en): 12:52 pm */ echo strftime($date_lang[3], $mydatefield()); /* output(de): Freitag * output(fr): Vendredi * output(en): Friday */ Maybe you have to check out which string in setlocale is working on your Server. Try different: setlocale(LC_ALL, array('fi_FI.UTF-8','fi_FI@euro','fi_FI','finnish')); //put out the first supported string echo setlocale(LC_ALL, 0);
    1 point
  47. Just wanted to mention some updates I was recently working on. 1. The Cheatsheet is now a ProcessWire Site (since couple months already). This allows for easy updating by team members. Also it allows for implementing stuff that wouldn't be easy with a static html. So all entries are now pages. This was very easy to setup and import the html data via a simple script. 2. Since we now got all the power of PW there, my idea was to create a API doc Site that would serve as a alternative extended sort of cheatsheet. Similar to php.net where you can see more details along with simple code examples and further information like what version introduced or if it's depreciated, related links to other API's. Also there's possibility to add comments. This opens great possibilities to give more information to you, add a "social" aspect, and at the same time also open it for indexing by search engines . You can see the current (not finished) version of the extended API doc here: http://cheatsheet.processwire.com/pages/built-in-methods-reference/pages-find-selector/ We are currently adding content and examples to the API's so this will take some time. Also there will be added some cross linking from the Cheatsheet to the extended docs when ready. Hope you like it. (edit: just realized that this was the 100th response in this thread! great coincidence)
    1 point
×
×
  • Create New...