Jump to content

Macrura

PW-Moderators
  • Posts

    2,765
  • Joined

  • Last visited

  • Days Won

    40

Everything posted by Macrura

  1. Some sites need widgets, as they have been called in some systems; a widget can be almost anything, like: tag cloud mini calendar menu quote rotator free text social sharing search contact info map This is a simple way to create widgets that can be shown in multiple "areas" of a page, as well as on specific pages. In this particular method you would need to setup each widget type you want and then determine how best to accept any necessary user input like content, pages select (like for a menu) or settings. This example uses include files for each widget type, and the name of the include file would match the name of the widget type, which is also a page field. In this example, I'm also using ListerPro to provide a widget management page. Fields The main fields used on this widget example are : title widget_location (page select - options in this case are footer and sidebar) widget_type (page select, you would configure your widget types as selectable options) pages_select (would be used for multiple pages and might apply to a menu widget) body - used for plain widgets selector (selector inputfield, used for telling the system where to show the widget) text_structured - for this i'm using a YAML field, but it could just as easily be a table; would depend on what you want to store; YAML would allow this single field to be used for varying requirements based on the widget type, but would be harder to validate and prone to user error; icon - a page select for an optional icon which is being used in the template, and would be shown as part of the widget. Files for each widget type you want to allow users to select from, you would need to create an include file with the markup for that widget, and then add that widget to the list of available widgets. here is an example for a site with several widget types: Selector & Output wherever you want to include the widgets (footer, sidebar etc.) you would run a $pages->find and then foreach through the widgets (in this case finding all footer widgets). In this case the (incredibly amazing new) selector field would be specifying what pages to show the widget on. We assume that most widgets won't have a selector specified, and will default to show the widget. if a selector is specified, we can check to see if this page fits the selector by using the $page->is($selector) syntax. <?php $widgets = $pages->find("template=widget, widget_location=footer, sort=sort"); foreach($widgets as $widget) { // check if the selector field is in use and if so, see if this page is supposed to display it: if( $widget->selector) { if( !$page->is("$widget->selector") ) continue; } $widgetType = $widget->widget_type->name; $include = file_exists("./inc/widget-{$widgetType}-foot.inc") ? "./inc/widget-{$widgetType}-foot.inc" : './inc/widget-footer.inc'; include($include); } ?> this example also has a fallback file in case the widget type is not specified, sort of a default. the widget's .inc file will be unique to your design and how you have it setup.
  2. right, i was using this parser http://yaml-online-parser.appspot.com/ and it helped since i could see a json output and make sure it would be correctly recognized.. but i agree that it would be too much hassle to validate.. maybe a simple tidy function that would at least trim whitespace at end, and remove blank/empty lines
  3. @owzim - is there any way to implement validation using the included parser, like for example if someone makes a mistake in a YAML field, the page throws a validation error...? or maybe a method where you could first check to see if a YAML field is valid, or maybe even have the field return null if the YAML is invalid.. thanks, just thinking out loud here, about validation possibilities..
  4. @kathep, sorry if this was already answered; this is how i'm doing it (the random quote is shown on pages that are in a page select called landing_pages; quotes are stored as pages.. we use the title field for the name of the person, and the summary field for the quote text, so there is no markup (since in my design the quote is displayed in an h3 <?php $quote = $pages->find("template=quote, landing_pages=$page")->getRandom(); ?> <blockquote> <h3><?php echo nl2br($quote->summary)?></h3> <cite title=""><?php echo $quote->title?></cite> </blockquote>
  5. for the most part, there is code on the forum to achieve this; I think ryan and adrian have posted usable examples; also, make sure to check the cheatsheet; I think one thing that trips up some people with the user management is how simple and easy it actually is; this is something you need to achieve with a custom form that interacts with the API. If you are good at forms, then you just make a form processor on the template and then process the post data how you want. The FAV links would be something that you would pull from the API; here i think you will need to use track changes, and then write changes back to the API. Sorry I can't offer anything more concrete, but if you post your code samples, and a more specific description of your setup (fields, templates, etc..) it might be possible to provide sample code.
  6. @pwired, I used Sublime Text in a situation like this, with Woocommerce; it can search multiple files for a string..
  7. @Teppo, here's the error; i think this only happens on pages that actually have history for some fields; there is a page where we can add pages to this field, and i think possibly the only difference is that there is no history for any fields on that page http://mysite.com/manage/page/edit/ Error: Exception: Can't save field from page 1951: /catalogue/name-of-album-changed/: Call $page->setOutputFormatting(false) before getting/setting values that will be modified and saved. [album_reviews] (in /home/someaccount/int/wire/core/Pages.php line 1110) #0 [internal function]: Pages->___saveField(Object(Page), 'album_reviews', Array) #1 /home/someaccount/int/wire/core/Wire.php(389): call_user_func_array(Array, Array) #2 /home/someaccount/int/wire/core/Wire.php(344): Wire->runHooks('saveField', Array) #3 /home/someaccount/int/wire/core/Page.php(1180): Wire->__call('saveField', Array) #4 /home/someaccount/int/wire/core/Page.php(1180): Pages->saveField(Object(Page), 'album_reviews', Array) #5 /home/someaccount/int/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTableAjax.php(110): Page->save('album_reviews') #6 /home/someaccount/int/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTableAjax.php(64): InputfieldPageTableAjax->addItem(Object(Page), Object(Field), Object(Page)) #7 [internal function]: Inputf
  8. @teppo - many thanks for replying and sorry for the vagueness of my bug report; to clarify, yes, there is a page table field where the ajax saving of the field fails when the Version Control is enabled for this template; i only have 3 fields enabled for VC, which are all simple text and body fields. I removed the template of the containing page from the VC preferences and that allowed the pt field to be saved. there were errors in the error log (cleared it though), but I'm not sure if they would help, but if so i can re-enable the VC on this template to generate the error if that would help... this site is still in testing, not live, so it's no problem to do that; i can probably get to that later today...
  9. i've had too much wordpress in the last 6 months. 130 hours building an ecommerce site using woocommerce; now 10 hrs restoring a hacked site for a friend who didn't backup. My message to anyone reading this who might try and Wordpress: Don't Do It!
  10. ran into a snafu today, here's the setup and behavior: - Page table field (called reviews) when adding a review, the review would save but then the field itself wouldn't save so the related page wouldn't be added into the page table and there would be a 500 error; tried uninstalling various modules, but in the end it came down to this one, when i removed the template from the selected list of templates, the field started saving again; i will try and provide more info, but the errors were not specific to anything other than setting output formatting as false for the the page table field before saving...
  11. @changwuf31: it is possible to print, but might require some additional code; for example you could do a printable pop up window; for now i'm hoping that my clients save a tree and use these built in docs for reference.. this is a huge thing, especially psychologically and from a perspective of workflow; because now my clients know that there are docs, and consequently will probably check there first before contacting me; and on the flipside if they ask me a question that is already covered in the docs, i can bounce back with 'did you read the docs?'
  12. @mrkahn - I've yet to see a way to represent nested pages in a multi-page select; it would be interesting if it were possible, but i think it would take some custom module. I guess you could create dummy pages that trigger a new dropdown and then the first item after that is the dropdown parent and then the subsequent items are the children of the first item; then you would need another dummy page to end the subnav; i think that would work, but it seems like a lot of work; I build menus using pages, so this makes it easy to build menus, publish and unpublish menu items, and have as many levels as needed with no extra work. It also allows you to have a custom title for every menu item, set an icon if you want, or classes, or use javascript as the menu item... here's an example site with 3 menus:
  13. @toothpaste - are you looking for something like any of these examples? I could post code for these if that helps: using processwire, search function - page reloads on select (this is great since you can bookmark results) http://www.ohmspeaker.com/speaker-finder/ using jQueryDataTables - no page reload, but also fast filterable results with many dropdowns: http://katonahartcenter.com/pages/daily-schedule/
  14. @lehtu - just a wild shot here - are you looking for wire('user') = ... ?
  15. if i was using pages for images, I would keep the images template published and not hidden, but i wouldn't make a php file for it. you can easily find your featured images by using this: $featured_images = $pages->find("template=image, featured=1");
  16. Hi Joss, ok sure - i'll take a look at the single selects and update the module asap; you're right that the need to quickly edit a select by going to its page is probably not exclusive to the multi selects... wonder if this could be enabled for radios and checkboxes... i guess when one one installs the module, you would comment out the areas you don't need, and also you can change the classes that the jquery targets to fine-tune which page selects get the edit links. you could also control if it loads in lightbox or new window or same window by changing the jquery wrapinner markup; we used a lot of 'new window' links on this record label site because it was easy to create or select a few artists and then click all their names and bring up all of the page editors for each artist in a new window.. here is the code needed to add to the js file: // add links to Plain Page Selects. Change the class to target specific fields. $('div.InputfieldSelect').each(function(){ id = $(this).find('select option:selected').val(); if(id > 1) { $(this).append("<div class='page-link'> <a class='edit-modal' href='"+config.urls.admin+"page/edit/?id="+id+"&modal=1' target='_blank'><i class='fa fa-edit'></i></a></div>"); }; }); i added this to the css to make the links into an icon that floats to the right of the page select; div.page-link { float: right; } this doesn't yet account for the change on the select; would need to write some more js to get the link to update if the select changes so the link would be correct before saving
  17. don't have much time, but does this help: <?php foreach ($page->my_items as $item) { ?> <div class="item"> <img src="<?php echo $item->my_image->url ?>" /> <a href="<?php echo $item->my_link->name ?>">View</a> </div> <?php } ?>
  18. ok, well in the current state it would be JqueryPageSelectEditLinks but once it is changed to hook into the render methods of the fields like InputfieldAsmSelect, then will it be a process module, or if not, i don't know what to call it - maybe AdminHelperPageSelectResurrectEditLinks
  19. so thanks to Soma, there will be a new version of this that doesn't require all of the jquery stuff; currently using soma's code and have it working for asm selects, so now just need to do the same for page list select and autocomplete...
  20. @mr fan - also there is something that needs to be fixed in the module: // attach js+css to the page only on edit page public function loadAssets($event) { if($this->process == 'ProcessPageEdit') { //load jQueryMagnific $this->modules->get('JqueryMagnific'); //load module scripts and styles for the list links $this->config->scripts->add($this->config->urls->ProcessPageSelectLinks . "ProcessPageSelectLinks.js"); $this->config->styles->add($this->config->urls->ProcessPageSelectLinks . "ProcessPageSelectLinks.css"); } } forgot the brackets after the conditional (copied original code from a module that only had 1 script after the conditional).. without this it will break the admin
  21. whoah - so how to enable.. ? guess that would make this module useless...
  22. @ozwim - thanks, again, yeah, sorry for being clueless about the name and how to load the magnific.. will work on fixing that - also if you have any suggestion for name let me know..
  23. yeah - open to suggestions, have no clue what to call this properly.. Use cases so far: - record label where there are albums and each album needs to have a page select for artists, but very often need fast access to edit that artist page. - during development when adding categories sometimes users misspell things, or maybe use the wrong word.. so easier to have that link right there rather than go click through the page tree - email app where a page is an email and users can be selected, but you might want to check that user's email address, or see/edit something..
  24. this is a work in progress... needs testing. in this module the edit links are added to the green boxes using 2 methods: jquery for the page list select and page auto complete, and the native asm select feature for asmSelects (thanks to Soma). Since the PageAutoComplete and PageListSelect are using the hover and icon from asmSelect, the asmSelect assets need to be loaded now on every page edit, in order to make the links look right. if you downloaded this before, please replace with the latest version, as there have been many changes, corrections/bugfixes and improvements. Please report any issues. Updated 12/6/14 at 10PM - please delete earlier versions due to issue with links being added on template editor. Updated 5/7/15: Module removed in anticipation of new official version release: https://processwire.com/talk/topic/9857-module-page-field-edit-links/?p=94599
  25. @Manol, thanks a lot, this helps to see that in context of something familiar.
×
×
  • Create New...