-
Posts
7,529 -
Joined
-
Last visited
-
Days Won
160
Everything posted by kongondo
-
I've noticed custom input areas or InputfieldText rendered in InputfieldMarkup and added to a fields 'details tab' are not getting saved when the field is saved. The values are sent alright. I can't find where and why in ProcessField.module ProcessWire is discarding them...The code below doesn't work... public function ___getConfigInputfields(Field $field) { $f = $this->modules->get("InputfieldText"); $f->attr('id+name', 'test'); $f->attr('value', $field->test); $f->label = $this->_('Test'); // ALTERNATIVE TO ABOVE..hence same 'name' (NOT being used together) $customInput = '<input type="text" name="test" value="'. $field->test .'">'; $markup = $modules->get('InputfieldMarkup'); #$markup = new InputfieldMarkup; $markup->attr('id', 'my_test_markup'); #$markup->attr('value', $f->render());// @note: input rendered but value not saved #$markup->value = $f->render();// @note: input rendered but value not saved $markup->attr('value', $customInput);// @note: input rendered but value not saved //$markup->value = $customInput;// @note: input rendered but value not saved $inputfields->append($markup);// @note: input rendered but value not saved //$inputfields->append($f);// normal method works return $inputfields; } Any ideas or this is it? Thanks.
-
if else failing (but working in HannaCode)
kongondo replied to Peter Knight's topic in General Support
yeah...ternary operator.. https://davidwalsh.name/php-shorthand-if-else-ternary-operators -
Hi Tom, Welcome to the forums . Maybe these two posts are helpful? https://processwire.com/talk/topic/7262-ckeditor-rtl/ https://processwire.com/talk/topic/13468-colors-in-ckeditor/?p=121618 (see the BidiRtl)
-
files method getItemsAdded() always return an empty array
kongondo replied to yuters's topic in General Support
Hi Yuters...welcome to the forums.. I got a bit of joy by hooking into InputfieldFile::processInput similar to what was done here. Didn't test much further since my code kept interfering with the files ajax upload (i.e. would prevent uploads)... -
hundreds children pages appeared (for-page-20xxx)
kongondo replied to gunter's topic in General Support
Where exactly are these zombie pages in the page tree? Under Admin or under some other non-admin page? -
What @adrian said... also see: https://processwire.com/api/coding-style-guide/#4-classes-properties-and-methods http://processwire.com/api/modules/ https://processwire.com/talk/topic/2394-how-to-present-your-module/
-
@csaeum, I have read your post several times but wasn't able to figure out what you were asking. Please clarify, maybe with some code and/or pictorial examples, thanks..
-
Yes,,,We've reported this to Ryan. In the meantime using the full URL works just fine.....
-
getModuleConfigData() not working with separate config file
kongondo replied to Robin S's topic in Module/Plugin Development
Sure. In Blog I had a very specific need hence implemented the save. I needed the initial settings before the user configured how they wanted to structure their blog... -
getModuleConfigData() not working with separate config file
kongondo replied to Robin S's topic in Module/Plugin Development
I am a bit lost here and am probably way off. To test things, I have installed my Blog module but did not do any manual save after that. My default settings are saved without doing any manual save...this is because I have this line in ProcessBlog...___install() $this->wire('modules')->saveModuleConfigData($this, self::configDefaults()); ...unless of course that is what you guys mean by manual save? I can immediately access the settings...e.g. did this in basic-page $settings = $modules->getModuleConfigData('ProcessBlog'); Edit: forgot to add...I still use the old way of setting module config + PW 2.7.3 -
Actually, my bad; the README and my post above wasn't very clear (have now updated them). Not all options apply to getMenuItems(). The reason is that if using MarkupMenuBuilder to output the menu for you, i..e using the method render(), the structuring of the menu (the <ul>, their CSS classes, etc) are taken care of by the method. In contrast, if using getMenuItems() what you get back are the menu items with all their relevant properties. The reasoning here is that you will use those properties as well as any other logic and/or options you want in your own custom recursive function (nested loops) where you have full control of the markup. That said, only 3 options (from the list of those applicable to render()) apply to getMenuItems(). These are default_title, default_class and current_class_level. default_class is applied to the item's property $m['ccss_itemclass']. Here is a revised navTwo.inc showing how you can pass custom options to the recursive function and applying the same as well as the 3 options that can be passed to getMenuItems(). head.inc is also slightly revised to pass $options to buildMenuFromArray() - @note: The new 4th argument in the function - @note: The custom options array - @note: Complete code for previous examples 1-3 can be found in these gists head.inc <div class="collapse navbar-collapse container" id="bs-example-navbar-collapse-1"> <?php include('./navTwo.inc'); // your CUSTOM options to pass to the recursive function buildMenuFromArray() $options = array ( 'submenu_css_class' => 'nested-ul-css-class',//CSS Class for sub-menus; you can use whatever index you want 'other_custom_option' => 'foo', 'first_class' => 'first', 'last_class' => 'last', 'current_class' => 'current', 'has_children_class' => 'parent', ); echo buildMenuFromArray(0, $menuItems, 0, $options); ?> </div><!-- /.navbar-collapse --> navTwo.inc <?php $mb = $modules->get('MarkupMenuBuilder');// get Menu Builder $menu = 'Main';// pass a title of an existing menu (i.e. a menu already built and published in ProcessMenuBuilder) // @note: only these 3 options will work with getMenuItems(); Only pass options if you need to; it is not mandatory $options4getMenuItems = array('default_title' => 1, 'default_class' => 'list-group', 'current_class_level' => 4); // grab menu items as Normal Array with Menu items (argument #2 = 1) #$menuItems = $mb->getMenuItems($menu, 1); OR $menuItems = $mb->getMenuItems($menu, 1, $options4getMenuItems);// if passing options /** * Builds a nested list (menu items) of a single menu from an Array of menu items. * * A recursive function to display nested list of menu items. * * @access private * @param Int $parent ID of menu item. * @param Array $menu Array of menu items to display. * @param Int $first Helper variable to designate first menu item. * @return string $out. * */ function buildMenuFromArray($parent = 0, $menu, $first = 0, $options = array()) { $out = ''; $has_child = false; $subMenuCSSClass = isset($options['submenu_css_class']) ? 'class="' . $options['submenu_css_class'] . '"' : ''; foreach ($menu as $id => $m) { $parentID = isset($m['parent_id']) ? $m['parent_id'] : 0; $newtab = isset($m['newtab']) && $m['newtab'] ? " target='_blank'" : ''; // if this menu item is a parent; create the sub-items/child-menu-items if ($parentID == $parent) {// if this menu item is a parent; create the inner-items/child-menu-items // if this is the first child if ($has_child === false) { $has_child = true;// This is a parent if ($first == 0){ $out .= "<ul class='main-menu cf'>\n"; $first = 1; } else $out .= "\n<ul ". $subMenuCSSClass .">\n"; } // item CSS $itemCSSID = isset($m['css_itemid'])? ' id="' . $m['css_itemid'] . '"' : ''; $itemCSSClass = isset($m['css_itemclass']) ? $m['css_itemclass'] . ' ' : ''; $itemFirst = isset($m['is_first']) && isset($options['first_class']) ? $options['first_class'] : ''; $itemHasChildren = isset($m['is_parent']) && isset($options['has_children_class']) ? $options['has_children_class'] . ' ' : ''; $itemLast = isset($m['is_last']) && isset($options['last_class']) ? $options['last_class'] . ' ' : ''; $itemCurrent = isset($m['is_current']) && isset($options['current_class']) ? $options['current_class'] . ' ' : ''; $classes = $itemCSSClass . $itemHasChildren . $itemLast . $itemCurrent . $itemFirst; $classes = trim(preg_replace('/\s+/', ' ', $classes)); $class = strlen($classes) ? ' class="' . $classes . '"' : ''; // a menu item $out .= '<li' . $itemCSSID . $class . '><a href="' . $m['url'] . '"' . $newtab . '>' . $m['title']; // if menu item has children if (isset($m['is_parent']) && $m['is_parent']) { $out .= '<span class="drop-icon">▼</span>' . '<label title="Toggle Drop-down" class="drop-icon" for="' . wire('sanitizer')->pageName($m['title']) . '" onclick>▼</label>' . '</a>' . '<input type="checkbox" id="' . wire('sanitizer')->pageName($m['title']) . '">'; } else $out .= '</a>'; // call function again to generate nested list for sub-menu items belonging to this menu item. $out .= buildMenuFromArray($id, $menu, $first, $options); $out .= "</li>\n"; }// end if parent }// end foreach if ($has_child === true) $out .= "</ul>\n"; return $out; } ?>
-
Nice one @Macrura! Maybe also cross-reference the original request here?
-
I see you copied and pasted more code than necessary. I have used your code and it works for me... First, you need to make sure you have the latest version of Menu Builder which has the method getMenuItems(), i.e. version 0.1.5 head.inc <div class="collapse navbar-collapse container" id="bs-example-navbar-collapse-1"> <?php include('./navTwo.inc');?> <?php echo buildMenuFromArray(0, $menuItems); ?> </div><!-- /.navbar-collapse --> navTwo.inc <?php $mb = $modules->get('MarkupMenuBuilder');// get Menu Builder $menu = 'Main';// pass a title of an existing menu (i.e. a menu already built and published in ProcessMenuBuilder) // grab menu items as Normal Array with Menu items (argument #2 = 1) $menuItems = $mb->getMenuItems($menu, 1); /** * Builds a nested list (menu items) of a single menu from an Array of menu items. * * A recursive function to display nested list of menu items. * * @access private * @param Int $parent ID of menu item. * @param Array $menu Array of menu items to display. * @param Int $first Helper variable to designate first menu item. * @return string $out. * */ function buildMenuFromArray($parent = 0, $menu, $first = 0) { $out = ''; $has_child = false; foreach ($menu as $id => $m) { $parentID = isset($m['parent_id']) ? $m['parent_id'] : 0; $newtab = isset($m['newtab']) && $m['newtab'] ? " target='_blank'" : ''; // if this menu item is a parent; create the sub-items/child-menu-items if ($parentID == $parent) {// if this menu item is a parent; create the inner-items/child-menu-items // if this is the first child if ($has_child === false) { $has_child = true;// This is a parent if ($first == 0){ $out .= "<ul class='main-menu cf'>\n"; $first = 1; } else $out .= "\n<ul class='sub-menu'>\n"; } $class = isset($m['is_current']) && $m['is_current'] ? ' class="current"' : ''; // a menu item $out .= '<li' . $class . '><a href="' . $m['url'] . '"' . $newtab . '>' . $m['title']; // if menu item has children if (isset($m['is_parent']) && $m['is_parent']) { $out .= '<span class="drop-icon">▼</span>' . '<label title="Toggle Drop-down" class="drop-icon" for="' . wire('sanitizer')->pageName($m['title']) . '" onclick>▼</label>' . '</a>' . '<input type="checkbox" id="' . wire('sanitizer')->pageName($m['title']) . '">'; } else $out .= '</a>'; // call function again to generate nested list for sub-menu items belonging to this menu item. $out .= buildMenuFromArray($id, $menu, $first); $out .= "</li>\n"; }// end if parent }// end foreach if ($has_child === true) $out .= "</ul>\n"; return $out; } ?>
-
Blog: Web hosting changes and upgrades for processwire.com
kongondo replied to ryan's topic in News & Announcements
@Ryan...shortened URLs in the modules directory don't seem to be working... -
@Marcel...what you do mean by the 'overview'? blog-posts page [the one with a summary of several posts] and/or the blog landing page? Anyway, it wouldn't work properly there since the count wouldn't be unique to each post...However, there could be other ways around that too, e.g. grabbing one post at a time in a foreach loop and replacing the post body for each...
-
Hi Alan, Sorry for the delay in getting back to you. The issue you are seeing is coming from the third-party module SchedulePages. As you are aware, in order to use the auto-(un)publish feature, one has to install this module. However, looking at these lines in the module code, I noticed that whereas it sets a date output and input format, it does not exclusive set a time input format (hence the hh24:06:ss that you are seeing). The solution is simple. Edit the two fields 'publish_from' and 'publish_until'. Specifically, visit their 'Input' Tab and select both a Date and Time Input Format.
-
@Marcel Epp, Currently that's not possible, at least not directly. The only option I see is that you get the output of renderPosts(), and do a string replace on the text at the beginning of the post body, i.e replace <div class="post-body">, prepending your page counter to it. Something like: // the start of the post body to prepend to. This is the string we will search for and replace $str2Replace = "<div class='post-body'>"; // your counter text + appended start of post body $page_counter = "<div class='post-counter'><h4>This is text for your post counter</h4></div>" . $str2Replace; // full post body to search and replace $str2Replace $postBody = $blog->renderPosts($page, 0, $postoptions); // the actual search and replace (prepend) $postBody = str_replace($str2Replace, $page_counter, $postBody); // final output $content = $postBody . $blog->postAuthor() . $renderComments . $blog->renderNextPrevPosts($page);//with post author widget
-
Example 1b is for buildMenuFromArray() actually...buildMenuFromObject() is for example 1a. Whichever you choose, you need to define the function first before you can call it...(i.e. the function code first, then echo it...)
-
Maybe 'coz it's on the 9th page?
-
OK, I'll try and replicate. As for the files, seems I wasn't clear, sorry. I just needed to see how you were calling menubuilder methods + the options you were passing to it Have a look here: https://processwire.com/talk/topic/4451-menu-builder/?p=120639
-
My intent was not to suggest that you use include_children as a solution. What I needed is more information to reproduce this. I have been unable to replicate you issue so the more information I have the better ...How the menu is constructed, the options, your environment, etc...basically, the whole code if that is possible....
-
Meanwhile, you can use filesize and format its output however you wish...
-
So I've decided to make the jump to Vagrant...leaving my beloved XAMPP behind. I was initially drawn to Scotchbox but it comes with some stuff that I don't need need - Laravel, all the node stuff as well as the caching stuff - and I couldn't find info whether it is customisable. My plan is to use either PuPHPet or Protobox (edit: I'll stick with PuPHPet) to customise my box the way I want. Either that or just install things manually (much like I set up my remote server)...I have done my reading and watched YouTube videos so I feel I am ready to take the plunge. I only need one machine (much like what I was doing with XAMMP) so will not be destroying anything soon. The most important things to me (apart from the LAMP stack of course) are automated DB backups and an environment where XDebug can work. I've never been able to have the thing work in XAMPP/Windows! Slightly OT but I might be ditching Sublime Text 3 in favour of Visual Studio Code. Tried it recently and was very impressed...if only Xdebug would work! (before you say it, yes, Tracy is nice for all other needs but what I want as well is something I can use to step through code)....OK, wish me luck...
- 28 replies
-
- 1
-
-
- vagrant
- virtualbox
-
(and 1 more)
Tagged with: