Jump to content

Roych

Members
  • Posts

    357
  • Joined

  • Last visited

Recent Profile Visitors

2,745 profile views

Roych's Achievements

Sr. Member

Sr. Member (5/6)

71

Reputation

  1. Im trashin pages every day automaticaly with: <?php $theDayBeforeYesterday = strtotime("-1 day"); // get our pages $reallyOldEvents = $pages->find("template=calendar-post, Start_date<=$theDayBeforeYesterday"); foreach($reallyOldEvents as $oldEvent){ $pages->trash($oldEvent); } ?> Maybe this helps here. I still get mail for every trashed item, no matter how many is there. Thank you
  2. Thanks for the update πŸ˜‰ Just noticed it always gives number 1, Right now I have 12 events all together if I add some new ones with older date (just for testing) it deletes them but the message in mail still says "there are only 1 ...."
  3. I used the first method not the message option, so not sure how to fix this, thank you.
  4. Hi, nice, this one works and sends mails exactly what I need. But is it possible to only get one mail if the number of remaining events is 7or lower, not for every event that goes to trash? maybe something like if ($numberOfItems = 7) { Just thinking here, I tried it and it still sends mails for every event that was put in a trash. And {$numberOfItems} doesn't work in the sent mail, but don't really need it if the mail would come just once when the number is 7. Thank you R
  5. Hello, I'm working on a restaurant site that deletes (puts in a trash) one children every day (daily menu). And I would like to send mail to administrator (of choice) that he has to add new children when there is only 7 left. As a reminder so that he doesn't forget about adding some new ones. We always show seven daily menus on frontend and we don't want go below this as it would look weird. Everything works great so far, I only need help with the mail sending as I never worked on something like this. Can this be done somehow? (I have FormBuilder, but maybe some hook would be better for something like this.) Im using Templates Daily menu (template=calendar-list) - day 1 (template=calendar-post) - day 2 (template=calendar-post) - ..... Thank you R
  6. Nice, took the first one, so I can have full control. Works perfect. Didn't know about "custom label field option" Will help alot in the future. Thank you very much R
  7. hi, well the pages can be sorted added and deleted but because alergens are usualy noted with numbers like #1 are always cereals and #5 are always Crustaceans. So when you add a new dish, it says it contains alergens 1,5,2,14, ... and would be easyer to see the number rather than count and read through all of them. So just static number for each would be ok I guess (I would add the right number to the right alergen). Or by sorting pages, so first is #1 and so on. Hope u understand πŸ˜‰ Thank you R
  8. Hello, I was wondering if it's possible to add numbers in front of a title in backend in page reference field: #1 title #2 title #3 title and so on. But only in admin. Would be great if automated when creating a new page. Thank you R
  9. hehe πŸ˜„ Well defining stuf and the calling them out. πŸ˜‰
  10. yes it does, it looks like it's working. Thank you very much. Actualy learnt something new here. πŸ˜‰ R
  11. Not sure for trashing the events but would something like this work? I need to leave yesterday published but all older ones put in a trash. <?php $preyesterday = strtotime("-2 days"); $ptrashed = $pages->find("template=calendar-post, Start_date>=$preyesterday"); foreach($ptrashed as $ptrash) { if(time($preyesterday) > $ptrash->getUnformatted("Start_date")) { $pages->trash($ptrash); } } ?> or <?php $eventpages = wire("pages")->find("template=calendar-post, include=all"); foreach ($eventpages as $eventpage) { $enddate = $eventpage->Start_date; $currenttime = time("-2 days"); if ($enddate < $currenttime) { $pages->trash($eventpage); } } ?> Thank you R
  12. Nice, it works great. Now only the datetime and putting in the trash. Defining the $yesterday simple. Thank you very much ;)
  13. Hello, I need some help with simple restaurant food menu, I'd like to show yesterdays menu and 6 future days (all together 7 days). My problem is that I'm not sure how to show -1 day with all future days. Another problem I have is that I don't need time in my datetime field ("Start_date") the menu should stay there entire day till midnight. But the day starts with 0:00:00 hrs and if I want the past event to go to trash, it goes in the morning not at midnight. (it puts todays event in the trash) Kind a lost here. it should show days like Wednesday (yesterday) | Thursday (today) | Friday | Saturday | Sunday | etc ... I show my "events" with <?php $events = $pages->find("template=calendar-post, Start_date>=today-1, sort=end, limit=7"); ?> <?php if(count($events)): ?> // my event code For dates I also tried with: <?php $today = date('d. m. Y'); $start = date('d. m. Y', $single->getUnformatted('Start_date') . " 00:00:00"); ?> And for trash I use: <?php $ptrashed = $pages->find("template=calendar-post"); foreach($ptrashed as $ptrash) { if(time() > $ptrash->getUnformatted("Start_date")) { $pages->trash($ptrash); } } ?> I'm not good with php so any help appreciated. Thank you very much for helping. R
  14. Hello, I'm strugling to create the menu, and somehow can't make it to look the same as original. It somehow works, but no quite right. Not sure what is wrong here. Any help appreciated. I need: <ul class="navbar-nav ms-auto"> <li class="nav-item dropdown"> <span class="nav-link active" data-bs-toggle="dropdown" aria-expanded="false"> Home <i class="ti-angle-down"></i></span> <ul class="dropdown-menu last"> <li class="dropdown-item"><a href="index.html">Home Layout 01</a></li> <li class="dropdown-item"><a href="index2.html">Home Layout 02</a></li> <li class="dropdown-item"><a href="index3.html">Home Layout 03</a></li> <li class="dropdown-item active"><a href="index4.html">Home Layout 04</a></li> <li class="dropdown-item"><a href="index5.html">Home Layout 05</a></li> <li class="dropdown-item"><a href="index6.html">Home Layout 06</a></li> <li class="dropdown-item"><a href="index7.html">Home Layout 07</a></li> </ul> </li> </ul> My code: <?php 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='navbar-nav ms-auto'>\n"; $first = 1; } else $out .= "\n<ul class='dropdown-menu last'>\n"; } $class = $m->isCurrent ? 'active' : ''; // a menu item $out .= '<li class="nav-item dropdown"><span class="nav-link ' . $class . '" data-bs-toggle="dropdown" aria-expanded="false"><a href="' . $m->url . '">'. $m->title .'</a>'; // if menu item has children if ($m->isParent) { $out .= '<i class="ti-angle-down"></i></span>'; } else $out .= '<li class="nav-item dropdown">' . '</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; } ################################## $mb = $modules->get('MarkupMenuBuilder');// get Menu Builder $menu = 1031;// pass an ID $options = array('default_title'=> 1, 'default_class'=> 'dropdown-item', 'current_class_level' => 6); /* 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)} ?> <?php // build menu from array (example 1b only) echo buildMenuFromObject(0, $menuItems); ?> Thank you very much R
  15. Exactly what I neded it works great now thanks for helping πŸ˜‰ yes the url to the file is in js so not sure how to call it outside of the foreach for each link (if u know what I mean). With the changed ID (above) it is now working great. Not sure if it is the best way but, no problems so far. R
Γ—
Γ—
  • Create New...