• Content count

  • Joined

  • Last visited

Community Reputation

39 Excellent

About MilenKo

  • Rank
    Sr. Member
  • Birthday September 17

Contact Methods

  • ICQ
  • Skype

Profile Information

  • Gender
  • Location
    Montreal, Canada
  • Interests
    Web development, coding, Network infrastructures, Linux, BSD, Windows, Cisco, Photography, Cooking

Recent Profile Visitors

380 profile views
  1. Ok guys, I guess being tired sometimes takes your concentration away. This morning I decided to use the same approach I used for the human readable time and the ISO 8601 duration is now fully working. As far as I can't think of a use for a period longer than X-days, I did not added the years format in human readable nor ISO but if someone needs it, just follow the logic and you will be good. Here is the code that I used: <?php $d = floor ($page->recipe_cooking_time / 1440); $h = floor (($page->recipe_cooking_time - $d * 1440) / 60); $m = $page->recipe_cooking_time - ($d * 1440) - ($h * 60); if ($d > 0) { $cooking_time = $d . 'd '; $itemprop = $d . 'D'; } if ($h > 0) { $cooking_time .= $h . 'h '; $itemprop .= 'T' . $h . 'H'; } if ($m > 0) { $cooking_time .= $m . 'm'; $itemprop .= $m . 'M'; } $itemprop = 'P' . $itemprop; ?> If someone has a more elegant approach, please share it. My goal was to remove any 0 days, hours or minutes if the time field calls for less.
  2. @LostKobrakai Even though you said that DateInterval is stupid, I found it as one of the sollutions but gave up on it as it blows an error on new DateInterval when the time is in minutes but not already in ISO format. I know I could either change the field to add the time as a text field and add there the time in ISO or else that would be easy to convert, however I am more eager to find out a more custom approach as in our life we could never know what to expect from tomorrow
  3. @LostKobrakai I checked the link you kindly provided, but this is to convert time in different formats but I do not see it doing it for the ISO standard. @Cengiz Deniz Thanks for the suggestion. It loos shorted for sure, now the question would be to make it work promptly for the format of days, hours, minutes as some recipes might require longer than 23h 59 minutes to prepare and I need to make sure that if day or hour are empty, they do not show as 0d 0h 25m (for example). But I will test your solution adding the day and see if that works or not. Still I am missing the ISO formatting. I believe I can do the same approach as with the human time modifying the code but will test today and if working will share it back.
  4. Hello. Working on my cooking recipes profile I need some time conversion to preptime duration as per ISO 8601. For the moment I have a few lines of code that take the value of $page->recipe_cook_time (in minutes) and convert it to human readable time for the frontend (ex. 1d 2h 35m): $d = floor ($page->recipe_cooking_time / 1440); $h = floor (($page->recipe_cooking_time - $d * 1440) / 60); $m = $page->recipe_cooking_time - ($d * 1440) - ($h * 60); if ($d > 0) { $cooking_time = $d . ' d '; } if ($h > 0) { $cooking_time .= $h . 'h '; } if ($m > 0) { $cooking_time .= $m . 'min'; } Now I am trying to convert the minutes of $page->recipe_cook_time into ISO 8601 duration (ex. P1DT1H35M) but am stuck and get different results instead of the right timing. Any suggestions about the conversion or even if you know of a function that can smarter convert minutes to human readable D:H:M ?
  5. Thanks for the suggestion cb2004. That could also do the trick
  6. Hello all. Yesterday working on my Cooking Recipes profile I stumbled across an interesting issue - how to show pages published/created on a specific time interval without the use of any plugins but just the default API of PW. Thanks to @abdus the sollution was implemented and was working perfectly fine (here) Everything was good until I started working on my main page and discovered that our web designer made the recipes appear in threee columns and to differentiate the columns he used 3 different classes (first, second, last). So it was supposed to look like this: <li><class="cs-recipes first"></li> | <li><class="cs-recipes second"></li> | <li><class="cs-recipes last"></li> At first I thought it would be easy to just create another loop and insert it within the first one, but that got me unprepared as instead of 5 posts (as the limit was), I was showing 15. So moving here and there, trying and trying for quite some time to find a solution, I got stuck and asked for some help. Mr @abdus saved the day again offering something simple and most important - fully working. As far as it was a PM, I decided that it would be a shame if I don't share it with anybody else who might sooner or later search for similar functionality, so here is the complete sollution that works perfectly fine and applies the first, second, last as it should without creating unnecessary loops etc.: Hope it helps and don't thank me, I am just the messenger
  7. Ok, now we got a better result Thank you @abdus
  8. @abdus I tested your code using DateTime class, but am getting a server error 500: $today = new DateTime(); $aFewDaysAgo = $today->modify('-2 days'); if($pages->get('/recipes/')->children) { $latest = $pages->find("template=recipes-inner, published>=$aFewDaysAgo, sort=-published, limit=9"); and the error in exceptions.txt is: Object of class DateTime could not be converted to string.
  9. Ok, so it looks like DateTime class would do the trick if I ever want to present some pages in a specific timeframe. Thanks again @abdus & @Robin S
  10. OK, that seemed to work and shows some results. Now if I want to show dates 2 or 3 days ago, would it be correct to have $start = strtotime( date(('Y-m-d')-2) . " 00:00:00"); or there is a better/correct way of doing it? Also let's say I need to show the pages for last 7 days?
  11. @Robin S Thanks for the advise. I thought so, but I am getting an error on my code: <ul class="cs-recipes"> <?php $start = strtotime( date('Y-m-d') . " 00:00:00"); $end = strtotime( date('Y-m-d') . " 23:59:59"); if($pages->get('/recipes/')->children) { $items = $pages->find("template=recipes-inner, $page->published>$start, $page->published<$end, sort=date, limit=9"); foreach($items as $rotd) { ?> <li class="cs-recipe"> <div class="cs-recipe-image"> <div class="cs-recipe-details-button"> <a href="recipe_single_layout_1.html">Details</a> </div> <img src="<?=$rotd->recipe_image->url?>" alt="<?=$rotd->recipe_image->description?>"> </div> <div class="cs-recipe-meta"> <span><i class="fa fa-hourglass-half"></i> <?=$rotd->recipe_cooktime?></span> <span><i class="fa fa-cutlery"></i> <?=$rotd->recipe_servings?></span> </div> <h3> <a href="<?=$rotd->httpUrl?>"><?=$rotd->title?></a> </h3> </li> <? } ?> </ul> Any ideas where did I messed it up this time?
  12. Hello all. I am trying to find a way to have a query with all pages that were published on a specific date (today for example). I read a few posts where people had a specific date field and were limitting the results by that, however is there a way to filter results without a specific date field? As far as I am able to publish the timestamp using $page->created logically I should be able to filter by the result of it? What is the best way to accomplish a filter for a day, week, month etc.?
  13. Hey Abdus, I just noticed that we are almost neighbors with you as I am originaly from Bulgaria and I flew quite a few times to my home via Istanbul :)

    As far as I noticed your blog in the signature and that you are working with Web design professionally I might have a few jobs for you if interested.

    As I am about to finish soon my IT Website, offering different IT services locally in Canada I would not miss to list the web development, so my idea is to establish some connections with good web devs and work through projects together (of course for the price agreed etc. that would be evaluated and confirmed in advance).

    Would you be interested for some future projects if a request comes to me?

    1. abdus


      Yep, sent you a PM

  14. @abdus I found the issue and eliminated it. It appeared that the problem was caused by another check for $nutrition->name before printing the $content if(!empty($item->name)) { echo $content; } ?> As soon as I removed the if-check as we are already checking up for empty $item->name before that it worked like a charm! The full code shared above has been edited to provide the fully working sollution.
  15. Yes, the text is 1:1 and if I only add another line it shows up every value promptly. Changing the metrics and quantity appears correct in the list too...