Jump to content

MateThemes

Starter
  • Content Count

    23
  • Joined

  • Last visited

Community Reputation

9 Neutral

About MateThemes

  • Rank
    Jr. Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I've got the same error here. I use the Image in a Repeater. Is there any workaround at this time? Although the module works fine, to have an error is annoying. Thanks for your help!
  2. MateThemes

    Datetime format

    Hello everyone. I have a question that i can't find a way to solve. I have following function in _uikit.php $date = $page->get('date|createdStr'); $dateModified = $page->get('datemodified'); But I need to output the $date in to different formats. My further function looks like this // return the blog post article markup return " <div> <article class='uk-article blog-post $class'> <meta property='name' content='$page->title'> <meta property='author' typeof='Person' content='Arra Lifte Harmanschlag'> <meta property='dateModified' content='$dateModified'> <meta property='datePublished' content='$date'> <meta class='uk-margin-remove-adjacent' property='articleSection' content='News'> <div property='image' typeof='ImageObject'> $featuredBlogPostImage </div> $heading <ul class='mt25 uk-margin-remove-bottom uk-subnav uk-subnav-divider'> <li class='uk-article-meta'> <time datetime='$date'>$byline</time> </li> </ul> <div class='mt25' property='text'> $body </div> </article> </div> "; Now I need to output the meta property in this format 2019-03-02CET05:23:00 and then a normal date format that is displayed on the Homepage with 2. März 2019 without time. Can anybody help me? Thanks in advance.
  3. I have found it! It was my mistake!!! In this function function ukAlert($html, $type = '', $icon = '') { $out = $type ? "<div class='uk-alert-$type uk-alert'><a class='uk-alert-close' uk-close></a><p>" : "<div data-uk-alert><a class='uk-alert-close' uk-close></a>"; if($icon) $out .= ukIcon($icon) . ' '; $out .= $html . "</p></div>"; return $out; } I have forgot to add uk-alert <div class='uk-alert-$type uk-alert' uk-alert> function ukAlert($html, $type = '', $icon = '') { $out = $type ? "<div class='uk-alert-$type uk-alert' uk-alert><a class='uk-alert-close' uk-close></a><p>" : "<div data-uk-alert><a class='uk-alert-close' uk-close></a>"; if($icon) $out .= ukIcon($icon) . ' '; $out .= $html . "</p></div>"; return $out; }
  4. Hello everybody! I use the Regular blog site profile as my starter template for my new website. I also use the included uikit.php with reusable functions. But I have one question to this uikit.php. If render an ukAlert the close trigger is not working. If i hard code the alert box, everything is working fine. Here is the code I use (it is not modified and is provided by the Regular blog site profile): /** * Render a uikit alert box * * @param string $html Text/html to display in the alert box * @param string $type Specify one of: success, primary, warning, danger or leave blank for none. * @param string $icon Optionally specify a uikit icon name to appear in the alert box. * @return string * */ function ukAlert($html, $type = '', $icon = '') { $out = $type ? "<div class='uk-alert-$type uk-alert'><a class='uk-alert-close' uk-close></a><p>" : "<div data-uk-alert><a class='uk-alert-close' uk-close></a>"; if($icon) $out .= ukIcon($icon) . ' '; $out .= $html . "</p></div>"; return $out; } /** * Render a success alert, shortcut for ukAlert('message', 'success'); * * @param string $html * @param string $icon * @return string * */ function ukAlertSuccess($html, $icon = '') { return ukAlert($html, 'success', $icon); } /** * Render a primary alert, shortcut for ukAlert('message', 'primary'); * * @param string $html * @param string $icon * @return string * */ function ukAlertPrimary($html, $icon = '') { return ukAlert($html, 'primary', $icon); } /** * Render a warning alert, shortcut for ukAlert('message', 'warning'); * * @param string $html * @param string $icon * @return string * */ function ukAlertWarning($html, $icon = '') { return ukAlert($html, 'warning', $icon); } /** * Render a danger alert, shortcut for ukAlert('message', 'danger'); * * @param string $html * @param string $icon * @return string * */ function ukAlertDanger($html, $icon = '') { return ukAlert($html, 'danger', $icon); } Here is the code in the template: <?php // did we find any matches? if(count($matches)) { // yes we did, render them echo ukAlert("Found $matches->count page(s)", "default", "check"); echo ukDescriptionListPages($matches); } else { // we didn't find any echo ukAlert("Sorry, no results were found.", "danger", "warning"); } ?> May someone have the answer to this! Thanks in advance!
  5. Hello everybody!!! It is me again with a beginner question. I have following function defined in uikit.php and used in my search-template <?php // did we find any matches? if(count($matches)) { // yes we did, render them echo ukAlert("Found $matches->count page(s)", "default", "list"); echo ukDescriptionListPages($matches); } else { // we didn't find any echo ukAlert("Sorry, no results were found.", "danger", "warning"); } ?> Now, how can I make the ukAlert translatable as a string? I didn't find a way to get it work! Thanks for your help in advance!!!
  6. Thank you very much for your answer!!! This helps me a alot!!! I am still new to Processwire but I love it more and more!!!
  7. Hello again!!! May someone can help me again!!! I have this to variables in my uikit.php $body = explode('</p>', $body); $body = reset($body) . ' '; what means explode and reset? And you see my funtion above, how can I summarize the text in the body field only with e.g. 10 Words? Thank you in advance!
  8. Now I get it!!! This is my code that i function ukBlogPostOverview(Page $page, $options = array()) { $defaults = array( 'summarize' => null, // Display blog post summary rather than full post? (null=auto-detect) 'metaIcon' => 'info', 'moreIcon' => 'arrow-right', 'moreText' => __('Read more'), 'categoryIcon' => 'hashtag', 'bylineText' => __('%2$s'), ); $options = _ukMergeOptions($defaults, $options); $title = $page->title; $date = $page->get('date|createdStr'); $datePublished = $page->get('date'); $name = $page->createdUser->name; $featuredBlogPostImage = $page->featured_blogpost_image; $body = $page->get('body'); $metaIcon = ukIcon($options['metaIcon']); $moreIcon = ukIcon($options['moreIcon']); $categoryIcon = ukIcon($options['categoryIcon']); $n = $page->get('comments')->count(); $numComments = $n ? "<a href='$page->url#comments'>" . ukIcon('comments') . " $n</a>" : ""; if($options['summarize'] === null) { // auto-detect: summarize if current page is not the same as the blog post $options['summarize'] = page()->id != $page->id; } $categories = $page->get('categories')->each($categoryIcon . "<a class='uk-button uk-button-text' href='{url}'>{title}</a> " ); if($options['summarize']) { // link to post in title, and use just the first paragraph in teaser mode $title = "<a href='$page->url'>$title</a>"; $body = explode('</p>', $body); $body = reset($body) . ' '; $more = "<a href='$page->url' class='uk-button uk-button-text'>$options[moreText]</a>"; $class = 'blog-post-summary'; } else { $class = 'blog-post-full'; } if($options['summarize']) { $heading = "<h2 class='uk-margin-medium-top uk-margin-remove-bottom uk-h4'>$title</h2>"; } else { $heading = "<h1 class='uk-margin-medium-top uk-margin-remove-bottom'>$title</h1>"; } $byline = sprintf($options['bylineText'], $name, $date); if($page->get('featured_blogpost_image')) { $featuredBlogPostImage = "<div class='uk-width-auto'><img class='uk-comment-avatar' src='{$featuredBlogPostImage->url}' alt='{$featuredBlogPostImage->description}'></div>"; } // return the blog post article markup return " <div> <article class='uk-article blog-post $class'> <meta property='name' content=''> <meta property='author' typeof='Person' content='Arra Lifte Harmanschlag'> <meta property='dateModified' content='2018-12-14T11:08:44+00:00'> <meta property='datePublished' content='$datePublished'> <meta class='uk-margin-remove-adjacent' property='articleSection' content='News'> <div class='uk-text-center uk-margin-top' property='image' typeof='ImageObject'> $featuredBlogPostImage </div> $heading <ul class='uk-margin-small-top uk-margin-remove-bottom uk-subnav uk-subnav-divider'> <li class='uk-article-meta'> <time datetime='2019-02-08T14:45:39+00:00'>$byline</time> </li> <li class='categories'> $categories </li> </ul> <div class='uk-margin-small-top' property='text'> $body </div> </article> </div> "; } Thanks for the help!!! Processwire has the greatest community, that is also a reason why I like this CMF so much!!! Have a nice day!
  9. Hello and thank you for your answer! I have following function added to uikit.php function ukBlogPostOverview(Page $page, $options = array()) { $defaults = array( 'summarize' => null, // Display blog post summary rather than full post? (null=auto-detect) 'metaIcon' => 'info', 'moreIcon' => 'arrow-right', 'moreText' => __('Read more'), 'categoryIcon' => 'hashtag', 'bylineText' => __('%2$s'), ); $options = _ukMergeOptions($defaults, $options); $title = $page->title; $date = $page->get('date|createdStr'); $datePublished = $page->get('date'); $name = $page->createdUser->name; $featuredImage = $page->get('featured_blogpost_image'); $body = $page->get('body'); $metaIcon = ukIcon($options['metaIcon']); $moreIcon = ukIcon($options['moreIcon']); $categoryIcon = ukIcon($options['categoryIcon']); $n = $page->get('comments')->count(); $numComments = $n ? "<a href='$page->url#comments'>" . ukIcon('comments') . " $n</a>" : ""; if($options['summarize'] === null) { // auto-detect: summarize if current page is not the same as the blog post $options['summarize'] = page()->id != $page->id; } $categories = $page->get('categories')->each($categoryIcon . "<a class='uk-button uk-button-text' href='{url}'>{title}</a> " ); if($options['summarize']) { // link to post in title, and use just the first paragraph in teaser mode $title = "<a href='$page->url'>$title</a>"; $body = explode('</p>', $body); $body = reset($body) . ' '; $more = "<a href='$page->url' class='uk-button uk-button-text'>$options[moreText]</a>"; $class = 'blog-post-summary'; } else { $class = 'blog-post-full'; } if($options['summarize']) { $heading = "<h2 class='uk-margin-medium-top uk-margin-remove-bottom uk-h4'>$title</h2>"; } else { $heading = "<h1 class='uk-margin-medium-top uk-margin-remove-bottom'>$title</h1>"; } $byline = sprintf($options['bylineText'], $name, $date); if($page->get('featured_blogpost_image')) { $img = $featuredImage($page->featured_blogpost_image->url); if($img) $featuredImage = "<div class='uk-width-auto'><img class='uk-comment-avatar' src='{$img->url}' alt='$cite'></div>"; } // return the blog post article markup return " <div> <article class='uk-article blog-post $class'> <meta property='name' content=''> <meta property='author' typeof='Person' content='Arra Lifte Harmanschlag'> <meta property='dateModified' content='2018-12-14T11:08:44+00:00'> <meta property='datePublished' content='$datePublished'> <meta class='uk-margin-remove-adjacent' property='articleSection' content='News'> <div class='uk-text-center uk-margin-top' property='image' typeof='ImageObject'> $featuredImage </div> $heading <ul class='uk-margin-small-top uk-margin-remove-bottom uk-subnav uk-subnav-divider'> <li class='uk-article-meta'> <time datetime='2019-02-08T14:45:39+00:00'>$byline</time> </li> <li class='categories'> $categories </li> </ul> <div class='uk-margin-small-top' property='text'> $body </div> </article> </div> "; } I wann add a featuredimage, as i added the $featuredImage but on my Page it only displayed the file name of the image. I don't know how to display the Image url. Thanks for your help!
  10. Hello!!! This is great!!! I use the uikit.php too! But i have one questions. If i customize the blog markup (i wanna add a featuredimage field) how to i get the image url, i only get the image name? I am new to use functions and i can not find a way. Thank you very much for your help!!!
  11. Hello everybody! Are there any News for Padloper 2 now? Thank you!
  12. Thank you very much!!! This works great!!!
  13. Hello everyone!!! Maybe I am missing something. First I need to say the module works now fine, but as i said, i am missing something. I have following html markup: <div class="uk-navbar-center uk-visible@m"> <!-- Main Menu --> <ul class='uk-navbar-nav'> <li class="uk-active"><a href="/">Home</a></li> <li><a href="/der-schiort/">Schiort</a></li> <li><a href="#">Test</a> <div class='uk-navbar-dropdown'> <ul class='uk-nav uk-navbar-dropdown-nav'> <li><a href="/impressum/">Impressum</a></li> <li><a href="/datenschutz/">Datenschutz</a></li> </ul> </li> </ul> </div> And following Menubuilder Code for the Menu: <?php /** * Builds a nested list (menu items) of a single menu. * * A recursive function to display nested list of menu items. * * @access private * @param Int $parent ID of menu item. * @param Array $menu Object of menu items to display. * @param Int $first Helper variable to designate first menu item. * @return string $out. * */ function buildMenuFromObject($parent = 0, $menu, $first = 0) { if(!is_object($menu)) return; $out = ''; $has_child = false; foreach ($menu as $m) { $newtab = $m->newtab ? " target='_blank'" : ''; // if this menu item is a parent; create the sub-items/child-menu-items if ($m->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='uk-navbar-nav'>\n"; $first = 1; } else $out .= "\n<div class='uk-navbar-dropdown'>\n<ul class='uk-nav uk-navbar-dropdown-nav'>\n"; } $class = $m->isCurrent ? ' class="uk-active"' : ''; // a menu item $out .= '<li' . $class . '><a href="' . $m->url . '"' . $newtab . '>' . $m->title; // if menu item has children if ($m->isParent) { $out .= '</a>'; } else $out .= '</a>'; // call function again to generate nested list for sub-menu items belonging to this menu item. $out .= buildMenuFromObject($m->id, $menu, $first); $out .= "</li>\n"; }// end if parent }// end foreach if ($has_child === true) $out .= "</ul>\n"; return $out; } ################################## /* grab menu items using MarkupMenuBuilder */ $mb = $modules->get('MarkupMenuBuilder');// get Menu Builder /* get menu the menu we want (i.e. a menu created and published using ProcessMenuBuilder) */ // we can pass the menu's Page, page ID, title, name or its menu items string to getMenuItems() #$menu = $pages->get(1299);// pass a Page $menu = 1041;// pass an ID #$menu = 'main';// pass a name // passing an array #$jsonStr = $pages->get(1299)->menu_items; #$arrayFromJSON = json_decode($jsonStr, true); #$menu = $arrayFromJSON;// pass an array #$menu = 'Main';// pass a title /* only these 3 options apply to getMenuItems() */ $options = array('default_title'=> 1, 'default_class'=> 'cool_menu_class', 'current_class_level' => 4); /* grab menu items as a WireArray with Menu objects */ $menuItems = $mb->getMenuItems($menu, 2, $options);// called with options and 2nd argument = 2 {return Menu (WireArray object)} #$menuItems = $mb->getMenuItems($menu);// if calling without without options; 2nd argument defaults to 2 ?> <?php // build menu from array (example 1b only) echo buildMenuFromObject(0, $menuItems); ?> How can I close the <div class="uk-navbar-dropdown">? Everything I've tried seems not to work! Thank you very much for your help!!!
×
×
  • Create New...