OllieMackJames

Members
  • Content count

    253
  • Joined

  • Last visited

Community Reputation

99 Excellent

About OllieMackJames

  • Rank
    Distinguished Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

4,235 profile views
  1. @Robin S and I thought it couldn't get any better and now you improve it again! Just tested it and it works, THANKS.
  2. @zoeck Thanks and how would I get what I want with $mypage code then? I believe when I use $mypage then I would need to change all templates to use $mypage in stead of $page and this way I can keep everything as it is, and just when I need it, I can swap the homepage, while even keeping the actual content on the page with id=1 unchanged. Maybe I want to check conversions to see which page converts better. I built my sites to generate action and my designers tell me that my pages are way too long, but hey I tested short and long and the longer pages until now ALWAYS outperformed the shorter pages. I tested design and found that design does not make much difference at all. It is the text and the flow of the text that makes all the difference. I tested video and found that text pages still outperform my videosalespages, but videos strategically placed elsewhere have doubled my conversions on my salespage. So the code below does just what I need, spot on, what can be wrong about that? /* fill in pageid of page to be used for content homepage*/ if($page->id == 1 && $page->page2use4homepage) { $p = $page->page2use4homepage->id; $page = $pages($p); } When I don't want to use the contents of the homepage, I just take the contents of another page. And whether that is good or not all depends on what one wants to do and to me this is the exquisite beauty of Processwire. It totally allows me to do what I feel is needed at any moment, even if that goes against the grain of what others consider not good. Like I said in my other post, there are definite reasons why I want to do this, it allows for using a homepage on a live site, then changing the underlying page that is used to pull content into the homepage. And the code above works like a charm! And what I also like about processwire is this wonderful forum, where people and help each other, so @zoeck , @kongondo, @louisstephens big thanks for taking out of your time and helping me, much appreciated.
  3. Whether I like it or not, I have to deal with this nonsense. Small sites have been fined in my country already for not having clear refund policies par example. What I do is have a contract with a third party who keeps all legal stuff for websites that are working in the EU up to date to EU laws. They tell me what kind of legal pages, privacy statements etc. etc. to have in place. They are also now working on checking what to do with the new privacy regulation. Once they have that ready, I'll just add or adjust what I currently have on my site. Of course this is not for free, but 80 euros or something around that order, is not too bad for some peace of mind. This is what I work with: https://www.webwinkelkeur.nl/ it is a Dutch site.
  4. OK, thanks all, I finally got it working, this is how I managed to do it: /* fill in pageid of page to be used for content homepage*/ if($page->id == 1 && $page->page2use4homepage) { $p = $page->page2use4homepage->id; $page = $pages($p); } Thanks all.
  5. @kongondo thanks for your thoughts and no offence taken - the opposite I value your and anybodies input and just realize I am not good at explaining what I want to do. For reasons mentioned in I DEFINITELY do want to use this code and am using it as below now, but hardcoded, so each time I want to change it I change the code in the template, but I want to do that without touching the template itself: /* fill in pageid of page to be used for content homepage*/ if( $page->id == 1 ) { $page = $pages(1213);} So that is why I want to specify the pageID, in this case 1213 on the homepage admin side via the field page2use4homepage. And I want the double if statement like mentioned in the first post. Let me try and explain it again: If this page is the homepage AND if the field page2use4homepage is filled THEN $page = $pages(get value from homepage-field-page2use4homepage and insert here) Hope that makes sense. I am aware this might go against what others consider done or not done, but hey, this is what I want to do so if anyone can tell me how to get the content of that field on the homepage into the code, great! So if I can invite anyone to just focus your coding smarts on how to make this happen, that would be great!
  6. I tried this as well and no luck either: if( $page->id == 1 ) { $page2use = $page->page2use4homepage->id; $page = $pages('$page2use'); I also tried: if( $page->id == 1 ) { $page2use = $page->page2use4homepage->id; $page = $pages({$page2use}); and also this without luck: if( $page->id == 1 ) { $page2use = $page->page2use4homepage->id; $page = $pages({echo $page2use});
  7. @zoeck thanks for thinking along. What I have done now is forget about the repeater field and just made a pagereference field called page2use4homepage I can call this with the following code which I checked that works: <?php echo $page->page2use4homepage->id; ?> What I now need is to take $page->page2use4homepage->id and use that, but that does not work either if( $page->id == 1 ) { $page = $pages({$page->page2use4homepage->id}); } thanks!
  8. OK I tried the following, but that does not work either: if( $page->id == 1 ) { $site = wire('site'); if (isset($site->page2use4homepage) { $xxxx = echo wire('site')->page2use4homepage; $out = "$page = $pages('$xxxx');" } else { $out = ' '; } return $out; } wow coding is not easy!
  9. @louisstephens thanks but that does not work. I must not have explained myself well enough, apologies. if( $page->id == 1 ) { /* this piece of code must only work if the current page is the homepage - CHECKED this works*/ -> if exist content of repeaterfield named page2use4homepage /*if this field is not filled, then forget about the code and just move on with the rest of the page* - this code is not there yet/ $page = $pages(repeaterfield->page2use4homepageID);/*this will tell PW to pull the contents for $page from $pages(xxxx), where xxxx is stored in the repeaterfield called page2use4homepage, so the question is how to get this value within this function? - my instructions say to use: echo wire('site')->page2use4homepage); but I don't know how to place that in the code so it works. That is where I got the server error*/ else just carry on and forget about this piece of code} What I need is the following code to be the result: if( $page->id == 1 ) { $page = $pages(xxxx);} Where xxxx is the id of the page to be used to pull content to be used for the homepage. What this code does is tell PW that if this is the homepage to pull the contents for the page from page with id xxxx. On the homepage I have a repeater field called sites, with one repeaterfield called page2use4homepage, the content for this field = xxxx and can be called upon within a template with the following code: echo $site->page2use4homepage; and within a function with the code: echo wire('site')->page2use4homepage; so the question is how to write code does this: 1 - check if the page is the homepage 2 - check if the repeaterfield page2use4homepage has a value 3 - if that repeaterfield has a value, get it and input that value in the following line in the place of xxxx ==> $page = $pages(xxxx);} Hope this makes sense. Thanks
  10. @louisstephens thanks for that, I tried this: if( $page->id == 1 ) { $page = $pages(1213);} And that works, but I want to take it one step further, on my homepage template I now have a site settings repeater field. One of these site variables is called page2use4homepage My instructions say if I want to access that in a function I need to do this: echo wire('site')->page2use4homepage; I now need to combine them that would mean: if( $page->id == 1 ) { $page = $pages(echo wire('site')->page2use4homepage);} But that gives me a server error. So I must be doing something wrong here. Thanks!
  11. OK, thanks all, I finally got it working, this is how I managed to do it: /* fill in pageid of page to be used for content homepage*/ if($page->id == 1 && $page->page2use4homepage) { $p = $page->page2use4homepage->id; $page = $pages($p); } and then @Robin S showed me that this could do the trick just as well, with less code: if($page->id == 1 && $page->page2use4homepage) { $page = $page->page2use4homepage; } Thanks all. FYI, here is the original question I have a question how to turn the pseudocode below into something that works in PW I have made a new field called page2use4homepage and added it to the homepage template, which shows this: <?php include("./basic-page.php"); Now to this basic page template I want to add code that does the following: if pageid = homepage -> if exist content of field named page2use4homepage $page = $pages(field->page2use4homepageID); else just carry on and forget about this piece of code} How would I write the above in PW code? Thanks
  12. started a new topic about the necessary code to add to template here:
  13. Just ran the copy repeater matrix action. Works great, thanks again!
  14. THANKS! @adrian and @Robin S You coding giants truly rock and are amazing! I wish I could reciprocate but man alive I wouldn't even know where to begin if it comes to coding. Am I ever glad to have found this wonderful processwire engine with it's amazing community of giants that allow us all to move forward. Best wishes to you coding giants out here!
  15. @Robin S wow! @adrian thanks for your answer. I feel privileged to stand on the shoulders of all you coding giants. I am just a user who runs into stuff and here I am within a day this wonderful community makes things happen. What I am doing with my sites would not be possible without you coding giants. So processwire coding giants, hats off to all of you and a big heartfelt thanks. To all processwire coding giants: may your days be blessed with incredible coding insights that make things happen for all of your personal and business endeavors and may this result in joy and whatever results you wish for in your lives! THANKS!!!