Jump to content

Macrura

PW-Moderators
  • Posts

    2,765
  • Joined

  • Last visited

  • Days Won

    40

Everything posted by Macrura

  1. yeah but a little api magic can cure that.. open up your tools or api playground and: $pp = $pages->get(1234); // page you're adding the children to the page table foreach($pp->children as $child) { $pp->page_table_field->add($child); }
  2. @Lance If I recall correctly, there is a setting for the page table field that will enable it to show items not created by the page table and show the option to add them. You would see that below the page table.
  3. This is a very simple way to display some instructions to the admin users. Before starting, you need to write some docs; they can be a hidden branch of your page tree, using basic-page, or a different template of your choosing. You should make each subject it's own page under the docs so you can output each one under an accordion trigger. Required Module: Admin Custom Pages 1.) Follow all instructions to install the module; Also add the ACP_scripts_and_styles field to the admin template. 2.) Make a new page under admin, called Docs or whatever; assign the process as described in the module instructions. 3.) Make a template in your themes directory to generate the output of the docs page. 4.) Select that template from the page select in the admin custom page you created. 5.) also make a folder to keep your admin custom pages scripts and styles; 6.) create a css file to use for the display output and some basic styles (like ol, ul li etc..) 7.) Add the custom css file to your ACP_scripts_and_styles field. You can use any output you want, but i'm using a nested accordion, which is provided here: http://tympanus.net/codrops/2013/03/29/nested-accordion/ this is the content of the admin custom page: <?php $docs = $pages->get(4259); ?> <div id="docs"> <ul id="cbp-ntaccordion" class="cbp-ntaccordion"> <?php foreach($docs->children as $doc) { ?> <li> <h3 class="cbp-nttrigger"><?php echo $doc->title ?></h3> <div class="cbp-ntcontent"> <?php echo $doc->body;?> </div> </li> <?php } ?> </ul> </div> <script src="<?php echo $config->urls->templates ?>_admin_custom/js/jquery.cbpNTAccordion.min.js"></script> <script> $( function() { $( '#cbp-ntaccordion' ).cbpNTAccordion(); } ); </script> you'll also want to add the provided css, js and fonts that come with the Nested Accordion; in the css file you'll need to point the fonts to the actual font directory, for example: /site/templates/_admin_custom/fonts/icomoon_arrows/icomoon.eot it should come out looking something like this: *if you are using Reno theme, you can customize the icon, like for example fa-book, which is used in this example: -- Thanks & Credits to Diogo for originally creating the ACP module, and for Nico for getting it to work with the new admin theme system...
  4. @Joss - yes, i'll post the complete instructions as a new thread in tutorials, and link to that here - would that be ok? here's a first draft... https://processwire.com/talk/topic/8392-simple-built-in-docs/?p=81303
  5. @Joss - using a super simple implementation now for docs, using admin custom pages and a nested accordion. obviously not as developed as your idea, but took about 20 minutes to setup and now this client can read the docs from their PW admin; screenshot: : *changed to single screenshot
  6. cool.. this is all working great... will update my other post with the changes to the required code to output... as far as uses: - use a field for quickly importing child pages using structured data - use for editable settings (site settings, sliders, portfolios, other jquery plugins with a lot of parameters) thanks again for making this!
  7. @Lance - I think you'll find that for the most part it is easiest to keep the pagetable pages as children of the page, but it will also depend a lot on your structure, and whether that page has children already, in which case put them somewhere else.. some examples of where i've use pagetables, and i think it will make sense: | Page | PageTable Children | |-----------|--------------------| | Album | Tracks | | Slide | Captions | | Portfolio | Images | | Vignettes | Vignette | i think if you use the reno theme and also lister pro, it actually won't matter that much where you put them; but in a lot of cases having them as children keeps things tidy and you can always get the relation of a pagetable item by calling it's parent. and you can add pages not through the page table, and it will pick them up and ask you if you want to add them. For PDFs, depending on the amount on one page, i might still consider good old repeaters
  8. I usually just need one template called 'option' with a title field and a container called 'option-index', also with only title. That I use for dozens of different page selects tree branches... Do all of your templates that require containers have different fields?
  9. Part III: Using YAML (part of structured data module). 1.) Install the module (make sure to install the new version, FieldtypeDataStructure) 2.) create the field for it (ex. settings_ds) 3.) Add some settings - these can be more sophisticated/nested than the settings above, because of the YAML structure options: - name: address street: 27 Hawthorne Lane city: New York state: NY zip: 10982 phones: main: (999) 888 9874 fax: (555) 548-5647 - name: social_media facebook: https://www.facebook.com twitter: https://twitter.com - name: global site_title: My Awesome Site tagline: Tulips Rule 4.) Get the field into your template: $settings_ds = $pages->get(1644)->settings_ds; 5a.) Option 1: Auto populate the $vars foreach($settings_ds as $setting) ${$setting->name} = $setting; 5b.) Option 2: Query the field with PW selectors (this is awesome): $address = $settings_ds->get("name=address"); $social_media = $settings_ds->get("name=social_media"); $global = $settings_ds->get("name=global"); this is cool because you can keep all the parts of a setting together as a group, and have multiple parameters like this: // address echo $address->street; echo $address->city; echo $address->state; echo $address->zip; echo $address->phones->main; echo $address->phones->fax; // social media echo $social_media->facebook; echo $social_media->twitter; // global echo $global->site_title; echo $global->tagline;
  10. @ozwim - awesome module, this will make me lose sleep. Is there any way to use get on the yaml without having to first create a new wire array and add the yaml to that.. for example, i have this YAML: - name: address street: 27 Hawthorne Lane city: New York state: NY zip: 10982 phones: main: (999) 888 9874 fax: (555) 548-5647 - name: facebook url: http://www.facebook.com - name: site_title value: My Awesome Site and i'm outputting like this for now, since it works: $settings_yaml = $pages->get(1644)->settings_yaml; $settings = new WireArray(); foreach($settings_yaml as $sy) { $settings->add($sy); } $site_title = $settings->get("name=site_title")->value; $address = $settings->get("name=address"); $facebook = $settings->get("name=facebook"); echo $address->street; echo $address->city; echo $address->phones->main; echo $address->phones->fax; echo $facebook->url; echo $site_title; TIA!
  11. I almost never use the default menu listing of the page tree; i make a custom page tree somewhere under a "Menus" page and then generate the menus there, as is mentioned by Kongondo above... works like a charm.. if you need help building it, let me know!
  12. @MarcinP - i don't see any problem with this, and you can always use the alternate template filename to limit the # of actual file templates you need to create... my philosophy is that I create as many of those family type relations templates as necessary; I don't think it really affects anything...
  13. Part II: Using a Profields Table [Note: this part requires you to own ProFields] 1.) Setup a field of type table for settings, I call it settings_table. It will have 2 columns, setting and value 2.) add it to your template (example would be if you had a settings template). 3.) Add some settings.. | site_title | My Great Site | |------------|-------------------------| | phone | (666) 777-8888 | |------------|-------------------------| | slogan | Tulips Rule | |------------|-------------------------| | facebook | http://www.facebook.com | 3.) Place this code in your _init.php or wherever you have global stuff.. replace the page number with the appropriate page number: $settings_table = $pages->get(1020)->settings_table; foreach($settings_table as $row) { ${$row->setting} = $row->value; } now you can do this: echo $site_title echo $phone echo $slogan echo $facebook - - - ...and one might wonder, what is to prevent a client from inadvertently changing the setting name or even deleting a critical setting and consequently breaking their site? with some jQuery, and the help of admin custom files (courtesy of martijn-geerts) you can disable any existing setting name from being edited. or deleted; add this to your AdminCustomFiles/ProcessPageEdit.js file: $(function(){ $('li.Inputfield_settings_table tr').each(function(){ setting = $(this).find('input[name*="_setting"]'); value = $(this).find('input[name*="_value"]').val(); icon = $(this).find('i.InputfieldTableRowDeleteLink'); if(value) { setting.addClass("disabled").attr('readonly', true); icon.removeClass("InputfieldTableRowDeleteLink fa-trash-o").addClass("fa-lock"); } }); }); this does assume that the table is named settings_table, the setting column is named "setting" and the value column is named "value". you can also add this to your AdminCustomFiles/ProcessPageEdit.css li.Inputfield_settings_table tr input.disabled { background-color: #e8e5e5 !important; color: #949494!important; } Here is a screenshot of this in action: Edit: added instructions to protect the settings names, prevent deletion, and change the color to differentiate the field status.
  14. @adrian - yes, i love that YAML thing; and as I see it there are maybe 4-5 good ways to do settings, depending on the site and the scenario; I usually use a profields table, and have 2 columns, and do a similar code as above to get the $vars, and i'm using this for a lot of things like slider settings, site settings, settings for javascript plugins etc.. where i need to have a ton of settings without much effort... For some things that are mission critical I make fields, especially if the setting can use a color picker, rangeslider, or select. the delimited textarea is good for beginners who maybe don't have profields, and who need a quick easy way to have some editable settings in the b/e.. and there should be an easy way to use the YAML field to do this; i guess i should try it and do another tutorial for using that for settings...
  15. 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
  16. You can make your custom sharing widgets using sharrre and PW.. doesn't take long! 1.) Download http://sharrre.com/ 2.) put sharrre.php in templates 3.) put jquery.sharrre.min.js in your scripts folder. 4.) add the new template to PW 5.) add new hidden page using that template; call it anything (example 'sharrre') 6.) include the script in your output; 7.) in your custom js file setup your js; make sure to put in the correct urlCurl to your page using the sharrre.php for example: /*-----------------------------------------------------------------------------------*/ /* SHARRRE /*-----------------------------------------------------------------------------------*/ $('#shareme').sharrre({ share: { twitter: true, facebook: true, googlePlus: true }, urlCurl: '/sharrre/', template: '<div class="box"><div class="left">Share</div><div class="middle"><a href="#" class="facebook">f</a><a href="#" class="twitter">t</a><a href="#" class="googleplus">+1</a></div><div class="right">{total}</div></div>', enableHover: false, enableTracking: true, render: function(api, options){ $(api.element).on('click', '.twitter', function() { api.openPopup('twitter'); }); $(api.element).on('click', '.facebook', function() { api.openPopup('facebook'); }); $(api.element).on('click', '.googleplus', function() { api.openPopup('googlePlus'); }); } }); Note: there are other themes - see the website... grab the CSS that goes with this JS setup: http://sharrre.com/example2.html 8.) somewhere on your page, put the relevant markup: <div id="sharrre"> <div id="shareme" data-url="<?php echo $page->httpUrl?>" data-text="Share this page"></div> </div> works for me on 3 sites so far.. - - - N.B. There is now a comprehensive module for social sharing buttons by Soma which is probably easier to setup and more flexible, though using Sharrre can still have some applications. Also, it is possible that Sharrre is no longer maintained and may not still work without some intervention... not sure as I have not researched this issue..
  17. @joss - like your idea; just spent 2 hrs making PDF files with screenshots, arrows and callouts for a client so they can go in and start editing their site.. of course I could make some a custom admin page and put a sidebar link to documentation; but an all-in-one dedicated module would be nice where you could add pages to some part of the tree for all of the docs and then have the module generate the welcome screen for the docs, with list view... (sorry to post after you closed this)..
  18. besides replacing the wire directory an htaccess, maybe also check your http hosts setting in config. (https://processwire.com/api/variables/config/) also maybe empty the sessions out of assets, as well as any cache files that might be in there; then disable modules one by one.. also install diagnostics module, and check your file/folder permissions
  19. i use forklift a lot; it has fairly advanced batch rename, but AFAIK nothing with random
  20. for the first Q, i don't know of that being possible, but you could try using admin custom files, and then use jquery.validate to do a client-side validation on the field in question... or maybe you need a totally custom module
  21. i think how i would do it is: template called treatment-list fields: title, items (items is a page select) on the pages you want to include some treatment lists, have a page select which selects the pages you have created using the treatment-list template. if you need treatment list included ad-hoc within content, then you make a hanna code like: [[treatment-list title=Over-the-Counter Treatments]] where the title matches; you could also mod the page select on the page where you select the treatment list to link to a popup of the treatment list so the editor could see what is on the list;
  22. @kixe - sorry for some misunderstanding/misreading of my post (it wasn't clear); what i was trying to say is you could the built in auto-name (in the admin): OR make your own 'simpler' module, which is what i was trying to give an example of. Since the module in question (Field Generator) uses a function with openSSL dependency and the OP was not able to get said module to work, the use of uniqid() is there to give the possibility of a random looking page name as an alternative; but it is probable that the results would not be much different than using Ymdhis as your field setting
  23. @gebeer - nice one, ok i see how that would work, b/c the lowest level user will always have only 2 roles and that lowest role
  24. you mean like this? https://processwire.com/talk/topic/1648-ok-to-change-page-name-path-after-save/?p=15232
×
×
  • Create New...