Jump to content

kongondo

PW-Moderators
  • Posts

    7,480
  • Joined

  • Last visited

  • Days Won

    146

Everything posted by kongondo

  1. @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..
  2. Yes,,,We've reported this to Ryan. In the meantime using the full URL works just fine.....
  3. Hi Hector, Welcome to ProcessWire and the forums. Best to begin here: http://processwire.com/docs/tutorials/
  4. 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...
  5. 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
  6. 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; } ?>
  7. Nice one @Macrura! Maybe also cross-reference the original request here?
  8. 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; } ?>
  9. @Ryan...shortened URLs in the modules directory don't seem to be working...
  10. @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...
  11. 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.
  12. @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
  13. 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...)
  14. Maybe 'coz it's on the 9th page?
  15. 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
  16. 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....
  17. Meanwhile, you can use filesize and format its output however you wish...
  18. kongondo

    Vagrant

    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...
  19. Works fine here...(2.7.3)...How are you building and generating the menu? Using includeChildren? Anything else?
  20. I agree about the error being a MySQL code...(Google n all that). Besides, in the 'pages' table, the created column is not a datetime but a timestamp. If you grep 'datetime' in /wire/ folder (dev branch), you get a result set with 15 files. Narrowing those down to Fieldtypes only you get 3 files. Narrowing these down to which ones have a column 'created' in their db schema, you get 2 files... \wire\modules\Fieldtype\FieldtypeFile.module \wire\modules\System\SystemNotifications\FieldtypeNotifications.module If you are on dev branch (I don't know about devns), my money is on #2
  21. You also have the module SchedulePages (that works with Lazy Cron) if you want to auto-publish/unpublish pages...
  22. A couple of reads.. https://processwire.com/talk/topic/10743-allow-page-numbers-isnt-404ing-when-content-doesnt-exist/ https://processwire.com/talk/topic/3765-404-when-using-pagination-on-multi-language-via-url-presegment-site/
  23. I am guessing that what Ivan is after is a Menu Builder MSN combo....as per the conversation we had....starting from here...and culminating with a PageArray here..If there was a possibility to do an in-memory $page->child = myOtherPage...(without saving)...hence assign non-native/natural children to parent menu items....that would probably solve his problem (the multidimensional bit) ...but that is not possible, If it were, don't know if getting in-memory children would work though...
  24. Welcome to PW and the forums @JeevanisM The link @Joss pointed you to has exactly what you want...i.e., creating thumbnail grab for pages..see under 'Resizing Images'... foreach($page->images as $image) { $large = $image->width(500); $thumb = $image->size(100, 100); echo "<a href='$large->url'><img src='$thumb->url'></a>"; } Whilst there's still need for better documentation, we certainly don't lack documentation about the basics...the stuff that will get you up and running with ProcessWire...I know it can be confusing at first but ProcessWire is really easy... A bit OT but as a beginner, I personally wouldn't install ProcessWire with a site profile unless I have first read up on how the different site profiles work (tutorials section in the docs). Why am I saying this? Because they contain some functions that really have nothing to do with ProcessWire but are helper functions created to suit those profiles that may confuse you (especially if you don't know what's coming from where). For instance, the renderNav() function you've pointed to. That is not part of ProcessWire but just a helper function created in those profiles. Instead, I would install ProcessWire without a site profile (aka the blank profile), create a blank template file in my favourite text editor and on my second monitor (if you have one ) open the ProcessWire docs about $page and $pages and start playing. Just plain PHP...no CSS and JS . Once I got the basics is when I'd start thinking about displaying cute DIVs . Sorry if I sound brash...just typing in a hurry...+ above is my personal opinion...'horses for courses'...they say..And if you've already gone through the docs, apologies...ignore me... Whatever your learning style, I hope you stay with ProcessWire. I promise you the benefits (once you get over the initial hurdle) far outweigh the initial pain of adjusting to a new system, especially one in which you have to type a bit of code PS; Don't let my post put you off from asking questions, mind...
  25. Probably not relevant in your case, but just an FYI, array_filter considers zero values as empties...Will be a gotcha in use cases where you actually want zeroes
×
×
  • Create New...