Jump to content

MilenKo

Members
  • Posts

    466
  • Joined

  • Last visited

Everything posted by MilenKo

  1. OK, I tested @abdus method and it worked like a charm. It takes the nutrition name, value and measure and puts them to the styling super easy. One thing I am thinking to improve is to put the items in a specific order but not as they are typed in the list. So getting back to the previous nutrition list Proteins: 45.3 g Calories: 650 kcal Fat: 30g Carbs: 1.2g Sugar: 0.5g Salt: 1.1g Saturates: 15g Fibre: 0.2g The usual presentation of nutrition goes in this order: Calories: 650 kcal Fat: 30 gr. Saturated: 15 gr. Salt: 1.1 gr. Carbs: 1.2 gr. Fibre: 0.2 gr. Sugar: 0.5 gr Proteins: 45.3 gr. If it were only these values, I could extract them using the $cal = $nutrition->get('name%=cal') approach, but the list might go big if I add vitamins, minerals etc. So is there a way to order the list in the array?
  2. @abdus Sorry, I got too quick to reply before reading the script properly. I guess it is the late hours work (or should I say early hours in here). I think your suggestion would work out of the box without the need of a plugin and as far as I might not need another instance of textarea to filter like the nutrition, I would start with it first. Basically what you provided is almost the complete sollution where I would only need to adjust the field names etc. Extreme grattitude! P.S. I will read about the Wire-array as it seems to be pretty powerful and useful.
  3. @abdus Thank you very much for the suggestion. It looks like a nice way to do it, however I would need to extract from the textarea field the calories and put them in a different spot too (besides the attached image I have another spot for the calories only). @Pixrael You have reminded me that I should get more and more familiar with the PW Mods as the two suggestions would be almost a perfect hit. So I will give it a try and see what would be the best approach. The "issue" I see is that different users would have their different order so I should grab the calories vaue to put in the specific place on the frontend and then post the rest in a table as shown on the image. But I feel much closer with your suggestions guys, so your advises were HIGHLY APPRECIATED! Once I have the code in place, I will share it to allow others to reuse it one day if a need be.
  4. Hello all. I am working on a Cooking Recipes profile and have a field recipe_nutrition where I add the nutritional values in a textarea field like: Calories: 2000kj Fat: 10gr Carbohydrate: 10gr Protein: 50gr Vitamin C: 10mg Iron: 20mg So I am using the explode function to separate the lines and it works fine (if I am just styling the values as text list), but now I would like to take the text content before and after the colon and add them in a table. Also I need to find first the line that contains Calories and print the value in frontend. As far as the lines are not added in a specific order, the Calories: 2000kj could be first, second, third line etc. In the perfect scenario the line should be checked for a specifict text (in my case Calories) and if it contains it to get the text after the : sign. Maybe there is a better approach to using API and modules to achieve a simple Nutrition table with all the values without creating a field for every value but grabbing it from a text content or else? Check the image for better understanding of the goal.
  5. Ok, I got it working with the initial query: $result = $pages->find("template=recipes-inner, sort=-recipe_views_counter, limit=4"); The issue was caused by the fact that I selected the recipe_views_counter to be Integer, but in Numeric Input Type I had Text by default. Changing it to Number (HTML5) did the trick. One less thing to worry about
  6. Tried again this morning using get instead find: $result = $pages->get("/recipes/")->child("sort=recipe_views_counter, limit=4"); The result was 26 recipes instead of the 4 limitted and I am not aware where it got 26 from as it is not the number of all available ones and is not even the views number. What am I missing here? As far as I removed the sort it works just fine: $result = $pages->find("template=recipes-inner, sort=-modified, limit=4"); So it seems like I am unable to sort by the recipe_views_counter only. Could that be because of the field being an Integer?
  7. Hello @rick and thank you for your reply. You are perfectly right that it was a typo, however the query result is still empty: $result = $pages->find("template=recipe_inner, sort=-recipe_views_counter, limit=4"); foreach($result as $most_views) { .... } It seems like the sort selector is not picking up posts... I am always forgetting about the miraculous Tracy Debugger so will check whit it what is wrong...
  8. Hello. Trying to implement Most visited pages on my recipe site. I already added a field called recipe_views_count and the code to count visits (for now not excluding the session): if (!$user->isSuperuser()) { $page->recipe_views_counter += 1; $page->of(false); $page->save('recipe_views_counter'); $page->of(true); } so all that part is working fine and I am able to see the counter incrementing. Where I am stuck is how to show the most viewed pages now and sort them by the number of visits (max. first)? Trying this: $result = $pages->find("template=recipe_inner, sort=-recipe_views_count, limit=4"); foreach($result as $most_views) { echo $most_views->title; } However something is not right as the query returns empty. If I remove the sort criteria it shows the proper number but for sure not taking into consideration the views count.
  9. @Zeka I think I found the issue as the query seemed perfectly right but was showing strange results. So I went back to check every template and found out that Categories page had assigned recipe-inner as template instead of categories. This would explain the strange result. Edit: After applying the proper templates as per the tree above, the query returns no results. I even deleted all the categories child pages and added them back to every recipe to make sure that at least a few of them would match with others, but still nothing.
  10. == Home == Categories (template=categories) == == Category 1 (template=categories) == == Category 2 (template=categories) == Recipes (template=recipes) == == Recipe 1 (template=recipes-inner) == == Recipe 2 (template=recipes-inner) == Tags (template=tags) == == Tag 1 (template=tags) == == Tag 2 (template=tags) So each recipe could have multiple categories or a single if needed. With the earlier provided code, $related is equal to the id of Categories page but not to the recipes containing the selected categories, hence $related->title shows "Categories"
  11. @Zeka I tried your suggestion and I am closer but the result of the query is not what is needed: Here is the code I used with a tiny modification to match the correct field names: $recipesCategoriesSelector = $page->recipe_category->implode("|"); $related = $pages->find("template=recipes-inner, recipe_category={$recipesCategoriesSelector}, limit=3"); foreach($related as $similar_recipes) { echo $similar_recipes->title; } The result I see instead of having the title of the recipe is the text Categories which is the name of the parent that I used to add child pages as categories. Any ideas what is wrong?
  12. @Zeka Will try your suggestion later on today and share if that works fine. Because I was thinking of another way to organize what is needed, but I don't want to flood the topic. Basically instead of finding matching pages I thought to add a field with PageSelect and pick up manually recipes that would have similarities. Doing so is not an automated process but in my case would allow to be used for drinks matching the recipe or other recipes that you would prefer to suggest (versus the automated). It is always good to have options so I appreciate your suggestion. Now I have an option to provide similar pages by tags, by "category" and manually select so it could even be set in the admin as a drop down box to choose which way to go
  13. @Zeka I thought about that too, however with similar products you can make completely different results sometimes so it won't be a match. Example would be using almonds/almond flour and coconut oil to pan-fry meat or make a cake
  14. Hello. I found this topic looking for some ideas about similar pages. Presently I am working on a cooking website and am looking at how to organize a block of similar recipes in the recipe view. What I have so far is a parent page Categories in which I am creating the child pages for every category. Then in the recipe template I have a field (recipe_category) to select one or multiple categories the recipe belongs to. If the recipe had only one category assigned, it would have been easy to get the result checking if there are others within the selected category however what would be the approach if a recipe belongs to multiple cats? I know I could use the recipe tags too for the sorting and in this case I could implement the tags weight solution provided in earlier posts however how would you suggest to find similar pages which would basically hold an array of recipe_category?
  15. @Sanyaissues I know its been a while since you posted the page in this topic but it really gave me an idea to try - the ingredients list. Could you share some ideas of the approach? The only way I can see it through is by using the repeater approach for every ingredient in the recipe but it has its downsides... Btw, I really like what your work as the page is very clean and the picture materials speaks for themselves.
  16. @adrian I am almost done with the website main html so will start this week/weekend to turn it into the theme I need. Once I star, I will delete from one post the Posted field and see if the date is preserved and what is more important - if it is the correct one. So we will know soon how would that work
  17. @adrianI am coming back with a little issue/question for the importer. After finishing the process I noticed that there is a field called date where the importer adds the post publishing date. So do you know if I delete the field the proper timestamp of the post will be kept?
  18. @adrian I have just ran the test again this morning using your latest update from GitHub and was super happy to find out that the posts import went OK and the comments time stamp is perfectly matching the original. The rest (tags, fields etc.) are not imported, but as I mentioned earlier I do not mind fixing them myself as I need to do a lot of crap cleanup beyond the scope of this topic and not related to the module import. So for now I am totally good to start my work and move the posts to their new home so THANK YOU! If you ever need me to test an import or else, I have my local copy set so I can always run it again and again. For anyone dealing with a migration like mine, feel free to work on your PW Profile (appearance, functionality) then import the WP content to a newly created page of your choice. Once this is done all you have to do is to make sure that the fields in the imported pages are matching the ones in the template you are going to assign the posts to. In my case initially I have imported 600 cooking recipes but the original profile did not contain the comments module yet. So after the import and assigning the imported posts to the recipe template, I lost my comments. To make it work, all I had to do was to assign the comments field to my recipes template and only after that to start changing the imported pages one. Voila, I am now off the WP for good and the work continues.
  19. Heh, no worries at all @adrian It is perfectly clear that your efforts are put of a good will and you have definitely helped a lot already so no need to apologize for anything. I just saw that MigratorWordpress has been updated 7 days ago and thought I missed your update. Will test the import once I get back toy place tonight and let you know how it works. So far, the only "issue" I had with the importer are the comment dates as I am certain I did not tag the recipes properly and want to edit each one to achieve my new strategy. But hey, no rush at all, OK?
  20. Ok. I installed the migrator and tested the latest version of MigratorWordpress. Pushed the XML file that I sent you earlier and with 2 timeouts everything got imported. Here are the results: 1. Home page title has been changed to one of the imported (just the name changes, but the properties are OK so it is easy to fix by renaming the page back to Home). 2. Comments date is still imported improperly (PENDING: Comment #22 Posted 10 minutes ago by Maria appears in the comment edit field). 3. Tags page is created in the import parent page as a separate child, however there are no Tags child pages imported from the wordpress tags. I will try later to import the pages with comments and approve them by applying the proper templates etc. so that I can check if on the frontend the date would change or would be the one shown in the admin (10 minutes ago). Once I am done with the test, will report back.
  21. @adrian not to be rushing you but do you have any updates on the Migrator to test? Nevermind, I should have checked the GitHub before asking. I will test it and get back to you with the results. Thanks for the update.
  22. Thank you very much, guys. It is amazing how many answers I got and what is more important some approach choices and suggestions. I will start playing and share the code if somebody is looking for something like that. I liked the idea of @Nukro to make the styles in an array however it won't be just a class change so it might be easier to use the approach of @Macrura and @fbg13 where I would use something like: if($x == 1){ ...some code... } if($x == 2){ ...some code... } if($x == 3){ ...some code... } etc. Again I am super pleasantly surprised how simple it is to work with PW and its API...
  23. Hello good people. I was looking today on a header styling that I would like to use in my next project where I want to grab X-amount of posts and place them in a grid with different sizes and layout (hopefully you will understand me better from the layout shown above ). So far I was able to pull an array of posts and present them on the front-end using identical code for all results, however I have never dealt with a similar presentation where the 1st and 2nd posts have one style, 3rd has another, 4th different again and so on. Let's say in this scenario I would grab some results with $pages->find(...) but how would then I apply the different styling for every result?
  24. @adrian it might worth to mention here, that my exported fiile could be messed up due to the several themes installed during the last 5-6 years of the site existence so if something does not work at 100% I would try to use another XML export to make sure it is working fine. Once you are ready with the latest version, I will proceed to test it with my export and another from demo WP.
  25. No worries @adrian Anything I can help - shoot straight. Helping one is helping the rest so I am sure the gratefulness is to follow. Especially when it is supported with the latest versions etc.
×
×
  • Create New...