Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/05/2015 in all areas

  1. Helllllo! I am working on a simple module / pet project for a module that inserts custom classes into specific templates for forms that are generated via the api. I use bootstrap a bunch and am always messing with the defaults in processwire, now it should be a simple manner to tweak my settings in the admin area. As this seems to be something that I keep needing I thought that others might as well. Right now the functionality is pretty simple: Select the templates that you want to override the default styling on. Set your new defaults .... Proffit. What I would like is maybe some suggestions for options or functionality that I should try for. I have never really deep dived into modules so this is a bit new to me, but as I am looking for a new development job I would push myself for something cool. https://github.com/MuchDevelopment/FormStyler/tree/master
    6 points
  2. A settings field based on a hooked Profields Table. When running the code (in the spoiler), superusers are able to edit, drag & delete all, while other users are limited to edit the setting only. (Thanks MacRura for the idea) Superuser sees: Everybody else sees: Code lives in the spoiler. Maybe some time I build a Module for this one.
    4 points
  3. Needed to show someone how to quickly setup some settings for various things in a simple text area: could be used for slider settings, site settings, etc; What it does: gives you a matching variable for each key of each line... 1.) setup a textarea field for the settings ; i'm calling it settings_ta 2.) add delimited settings, 1 per line; i use a pipe (|) delimiter; example: address|some info here facebook|https://www.facebook.com twitter|https://twitter.com phone|(999) 999-9999 3.) in your _init.php, get the settings - replace the page number and the name of your settings field: $settings_ta = $pages->get(1644)->settings_ta; $settings_lines = explode(PHP_EOL, $settings_ta); foreach($settings_lines as $settings_row) { $settings_pair = explode('|', $settings_row); ${trim($settings_pair[0])} = trim($settings_pair[1]); } more condensed version, for those of you who like brevity... foreach(explode(PHP_EOL, $pages->get(1644)->settings_ta) as $settings_row) { $settings_pair = explode('|', $settings_row); ${trim($settings_pair[0])} = trim($settings_pair[1]); } now you can do this in your templates: echo $address; echo $facebook; echo $twitter; echo $phone; Edit: made the code simpler....; 2nd edit - added trim to support using ace editor with tabs Addendum: as an added convenience, you could use the Ace text editor module which would give you a monospaced text field and the ability to use tabs for your settings, which could be more readable and easier to edit. The code has been updated to support this by trimming the exploded strings prior to generating the variable/value. address | some info here facebook | http://www.facebook.com twitter | http://twitter.com phone | (999) 999-9999
    2 points
  4. This ProcessWire module allows you to import and parse XML files (using xpath) to create or update pages. [detailed instructions at github] Settings After successfull installation go to Setup > Import Pages From XML to start using the XML Importer. This module does not support all available field types. Nevertheless, I've refrained from restricting the supported field types because many of them should work by default. Xpath Mappings If you want to take advantage of references between fields in your xpath mapping then make sure the fields you're relating to are placed before the ones which need the relations. You can access and use any values/fields that you placed earlier in your file. Use $field_<fieldname> to match the desired value. Example: <?xml version="1.0" encoding="UTF-8"?> <songs> <song track="2"> <title contact_id="1">Some song title</title> </song> <song track="7"> <title contact_id="2">Just another song title</title> </song> <contact id="1" name="Sesmallbos" mail="info@test.org"/> <contact id="2" name="Sebigbos" mail="info@exam.ple"/> </songs> context: //song field order: title, track, contact_id, contact_name, contact_mail contact_id must be placed before contact_name and contact_mail first get contact_id : title/@contact_id then use that value as relation : //contact[@id=$field_artist_id]/@name as well as //contact[@id=$field_artist_id]/@mail
    2 points
  5. Not in my example , they only can remove the value, not the variable.
    2 points
  6. I'm a fan of a good sarcastic gif or better yet
    2 points
  7. I have never really delved in to this, but would love to see a fully realized example using this method. I often stumble over how one manages manual page selection by the user for seo purposes. I would love to have a page with a combination of pagination and infinite scrolling.
    2 points
  8. I just rolled it out on my photography portfolio, as the hoster is super active in tech. stuff and has already automated most of the hard work of setup. Went nearly to well. 3 ssh commands and some "I Agree" statements and I'd my site encrypted in about 10 minutes.
    2 points
  9. You may use one of those ready to use JS Libraries for Infinite Scrolling you can found on the net. One that I know and have used myself is IAS. In PW you must use pagination as you explained above, also have to render the NEXT button, but with display:none in CSS to make it invisible. The JS-Script will pick it up and loads the next portion when the user scrolls down.
    2 points
  10. I discovered this by chance and wondered why it never got answered. So here it goes: PageTable field is just holding a PageArray. You'd then use $a->remove($key) where $key can be the key or a page object. Then save the page. // remove page $item from PageTable $page->pagetablefield->remove($item); $page->save();
    2 points
  11. I will share a little texformatter from a actual project for a client. In my former CMS i had an easy addon where i could preset terms like in a glossary that will replaced in the Wysiwyg fields on every page. So there are solutions that i know but the all work not that easy like my former used addon. The title of the glossary_item is used for the termsearch. This textformatter search for terms in ||termexample|| or ||example term|| and replace them complete. If a term was in ||pipes|| and there was no hit in the glossary entries the pipes will deleted from the term and only the clean value will returned. So no room for wrong user entries like if i used HannCode or something else. This is great for abbreviations, external- and internal links and could extended for every possible replacement that makes sense like footnotes and so on. I like the pages concept for content and so i use pages for glossary and simple replacement where a user wanna have it. No autolinking without control, easy use pipes on abbreviations and links and it simple works. Some explanations from the Github Readme: Setup You have to use a pagestructure for the glossary items holder Page for entries template "glossary" glossary items template "glossary_item" The type of a glossary item could be a abbreviation, a external or internal link. Everything you need could added to the textformatter like more complex stuff, footnotes or other replacements. Why? There are working solutions like the great module from Ryan Cramer Autolink in the Profields https://processwire.com/api/modules/profields/autolinks/ But here Users don't could setup easy the terms to replace - this is only ment for webmasters or admins. There are a module for abbreviations from sunlix https://processwire.com/talk/topic/7467-module-processabbreviate/ But here i only have options for abbreviations and i couln't easy add stuff or replacments i need. Links Github: https://github.com/mr-fan/TextformatterGlossary Example Templates for Import: https://github.com/mr-fan/TextformatterGlossary/blob/master/template-examples.json Best regards mr-fan
    1 point
  12. I guess when you add an extra column to that table you can can solve it with PHP. The script loops over over each row, and you could modify it as you wish.
    1 point
  13. @Martijn - thanks - that's very cool. I like the idea of the label - so i'm going to see about integrating your version into my current project's settings table... It is definitely more user friendly to have the label - some clients put wrong stuff into value because they only see the variable name and sort of don't get it. Also in newer versions of my settings i have an options column, which inside i can place pipe-delimited options, such as enabled|disabled, or true|false, or on|off; then in the value row, when you click into the cell, it brings up a select; this helps to control the spelling and to also remind people of what sort of values are acceptable for the field. To achieve this i'm using a commercial jQuery plugin called Pickle, which lets you create a select out of any text input;(if i could find a non-commercial plugin that did the same thing i would post the instructions here)
    1 point
  14. Hey Adam, Did you ever get a working solution for this? I haven't tried to code anything up yet, but thought I'd be lazy and see if you had anything to share first
    1 point
  15. Great project idea. Would this allow me to use different settings for different templates? I'm making front end forms with the API but the different forms need their styles adjusted independently.
    1 point
  16. Thanks bitpoet. Must have overlooked the clone function. And yes you understood it correctly that I wanted to create those virtual instance only on rendering. In the end I however decided to create real pages kind of like MuchDev suggested via module by hooking into the save function of the single-event pages. The admin for the single-event template now looks like this: https://monosnap.com/file/t187kaF2xI7WxF79blA3D982uMT1ko The code for the module is as follows. Adapt it for your needs <?php class recurringEvents extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Recurring Events', 'summary' => 'Adds a function to create recurring events and add pages to Processwire when a checkbox is checked on page save', 'version' => 1, 'autoload' => true, ); } public function init() { $this->pages->addHookBefore('save', $this, 'hookSave'); } public function hookSave($event) { $page = $event->arguments[0]; # check if recurring is checked on the page beeing saved. if ($page->recurring==1) { $intervallString=$page->intervall->title; for ($i=1; $i <= $page->n_repeats; $i++) { // create new page $k= new Page(); $k->template = 'single-event'; // set template $k->parent = wire('pages')->get('/events/'); // set the parent $intervall='+'.$i.' '.$intervallString; // construct the $intervall selector for strtotimestamp +1 week or +1day, increase with iteration by 1 $k->setOutputFormatting(false); // Copy page fields from current page to newly created one $k->title=$page->title; $k->organisation=$page->organisation; $k->type=$page->type; $k->location->address=$page->location->address; $k->body=$page->body; $k->recurring=0; $k->dateStart= strtotime($intervall, $page->dateStart); $k->dateEnd = strtotime($intervall, $page->dateEnd); $k->save(); } $this->message("Sucessfully created ".($i-1)." copies of recurring event {$k->title}"); // on the current page set recurring to 0 again, no page->save() needed because the page will be saved after the hook automatically $page->recurring=0; } } }?>
    1 point
  17. MuchDev, this looks cool! How about ready presets for most popular css frameworks out there (bootstrap, foundation etc)? Ryan has those in FormBuilder, probably ok to use those in different context too (I have already asked, waiting for answer).
    1 point
  18. If you've unpublished the batcher's admin page, so it can probably not be cleanly uninstalled, so the page remains. On reinstall it's trying to recreate the still existing admin site and that fails. Just make sure you remove this page (Admin>Setup>Batcher) before reinstalling the module.
    1 point
  19. Updated module on dev branch. New features for v.0.0.9 dev branch : Added hook method ___beforeRender(), you can check hook example for usage Added multiple icons library use option Added Ionicons Library Now module using cdn for load icon fonts Also if you need custom icon font options you can use berforeRender hook ! After some test i will update also master branch. if you want to make test, you need to download and update it manually.
    1 point
  20. Good idea - though to be in keeping with the joke the module would have to demand weekly updates to avoid catastrophic bugs.
    1 point
  21. Sorry i am to busy with work and i know the issue. I think this issue appear, because fonticonpicker js library changing the processwire field attributes. I will do one more hidden field for fonticonpicker js attributes and after done i will update processwire field. Started to work on it. Thanks for interest !
    1 point
  22. Votes are in, and nearly unanimous: The module will be renamed to RockettForms when I get back into it. (Unable to commit enough time at the moment, but will get there.) Also, I plan to make this a 2.7-only module. If you think I should drop that to 2.6.1, let me know.
    1 point
  23. it's a good question - i thought there was (maybe i'm imagining it) some setting where you could tell it what to do with trashed items, e.g. trashed items are deleted, or left there; ran into a situation yesterday where we wanted to move a child item from one parent to another, but even moving it just allowed it to be on 2 page tables, because the 1st page table remembered the id, and didn't account for the fact that the item was no longer a child of the page table.. ended up being easiest to trash the page and then move it out of the trash to the new parent; but i could see there being a need in future to be able to elegantly move pagetable items around without too much hacking...
    1 point
  24. if you use Page::loaded, it would be good to add that hook conditionally (like if $this->process == 'ProcessPageEdit', before attaching the hook). Otherwise that hook will get called on every single page loaded in the system -- that's great if that's what you want, but not so great if you are trying to deal with something very specific. If you are loading hundreds of pages in a request, this could be more overhead than you want. Even if you attach it conditionally, it could still involve overhead. For instance, if the page you are editing has Page reference fields, it's going to get called for every page in that page reference field too. Whereas something like ProcessPageEdit::execute would only get called once. But if Page::loaded suits your needs the best, then you could find more efficiency in removing the hook after it's done what you need, so that it doesn't get called any more: <?php public function init() { if($this->process == 'ProcessPageEdit') $this->hookID = $this->addHook(...); } public function runHook($event) { // run the hook // ... // remove the hook $this->removeHook($this->hookID); }
    1 point
×
×
  • Create New...