Jump to content

bwakad

Members
  • Posts

    450
  • Joined

  • Last visited

Everything posted by bwakad

  1. I also agree with onjegolders and ryan. As I started with the examples out of this topic as well as skyscrapers, at one point I could not see what certain things were doing. It took me some time to get used to the API and template system. I then started from the DEV branch, and I now build day by day to make it more dynamic. Later on I will manage smoothness.
  2. Starting to like the way PW make things happening! Dynamic all the way... When I am on a page the happens to be the same name as my field for page selects I can simply do: $filter = $pages->find("template=products, limit=50, sort={$page->name}"); foreach ($filter as $child) { // and I can even output my custom field value without even writing the field name: $field = $page->name ; echo $child->$field->title ;
  3. this is the code I started with: $item = $pages->find("template=child-template, provincie=drenthe"); $map = $modules->get('MarkupGoogleMap'); echo $map->render($item, 'map');
  4. Error: Call to a member function first() on a non-object (line 175 of C:\xampp\htdocs\host\site\modules\FieldtypeMapMarker\MarkupGoogleMap.module) Installed MapMarker Fieldtype and Map Markup (google maps). Added this in my header: <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> The field is called map. It's added to my template. The current page has values entered for this field. this is in my template: $map = $modules->get('MarkupGoogleMap'); echo $map->render($page, 'map'); Do I need to add something else besides the module?
  5. Looks like I am old fashion, I often think "was not PHP invented as such?" : <ul class="inline"><li><?php echo "something funny";?></li><ul> When I would have used single qoutes or the way Joss's example it get's complicated. btw, I see a lot of people on this forum use Hanna's code, but is it not just something like wordpress has?
  6. PW is awsome! my URL is " host / provincie / drenthe " my URL is " host / branche / overheid " All my parent pages : provincie, branche, etc are using 1 template file "select.php" All my child pages are using a template file called after the parent, e.g. "(parent).php" Those (parent).php files only have 3 lines of code for including: header.inc browse.inc // has the code shown below footer.inc My fields are "provincie" and "branche" as you would have noticed a page select. "browse.inc" file is the holder for most of my code (layout and structure) and before my code display anything I now have this: $field = $page->fields->get("name"); // this returns the name = 'provincie' $selects = $pages->find("template=child-template, {$field}={$page->id}"); // this returns the value = 'drenthe' I could have used: $selects = $pages->find("template=child-template, provincie={$page->id}"); // this returns the value = 'drenthe' But then I could not use browse.inc anymore and had to do this for each field on each template. I am no to good with PW and wonder if this could be improved?
  7. I now started to use normal html and use the normal php inside: <img id="photo" src="<?php echo $child->image->getThumb('thumbnail');?>" /> this saves me from mistakes. Because using either double or single qoutes, with more and longer lines where you would have 2 or maybe 3 parts of php AND maybe some classes for CSS it get's confusing. I used to do $out = ."html code {php code} etc. and on the next line about the same. Eventually making echo $out; I believe they call it something like concacating? Then I read on internet single qoutes are faster because double qoutes need to be readed all the way before output takes place. But again, the qoutes get's me confused when combining everything. It's also better to use $out = instead of $out .= So what is the way you all doing it without errors - what is the better way?
  8. haha! thanks, I have been told before. I'm so much into details I often stay focused to long on one subject. But I start to see it. Keep patience! Host/provincie/drenthe/something/ (the something page does NOT exists) - it displays 'oei!' So basically this means prevent from entering some kinda fake url, or perhaps redirecting is trying to search with browserbar or maybe give some extra url's. I am thinking SEO advantage... Anyway, I now have to resolve my issue with the $child->url, which is suddenly changed to host/provincie/drenthe - where as it should read: host/parent/itemtitle My bad, had to use echo. Anyway, thanks to soma (looks so angry on the avatar ), pete, adrian, and martijn I can continue. I am really happy you all are so patient. @martijn - it's difficult to me how to present what I have in the system (page tree / templates) to make readers understand it - so if there is a preferred way that people use, I will be happy to do that in future. No problem . Just tell me how most of you want it. Or perhaps make a topic in PUB/DEV TALK for it? And thanks again, you always do your best to explain to a 'hard nut' lol.
  9. I get my list according to the 'provincie/drenthe'. showing childs with the field 'drenthe'. But the link to the item title for each child is pointing to this page back. <a href="<?php $child->url;?>"><?php echo $child->title;?> Do I have to change this to root or something? Yes, I did. It's funny you call it tralala. But what exactly should tralala represent? If not a page? Perhaps a user text input or something? How would you get this in the url?
  10. @martijn - I tried it on the current page, I don't see on what other page I would get the last piece (drenthe) in the url. root = home page - provincie(page current) / select template - - drenthe (page child) / provincie template ---------------------------------------------------- On current this code : if ($input->urlSegment1 == 'drenthe' ) { echo "Oei !"; } did not display anything.
  11. Oooohwww..... That looks so simple! I can't believe I was going for that difficult thing. Stupid stupid stupid. And thank you so much! But this only leaves me with when are we using url segments then? I did not get it when he said 'for pages that don't excist'? I mean, how would you get the url segment if it in the first place did not excist?
  12. For the life of me, I have now made all templates URL segment enabled. Restarted Xampp. Cleared my brower. Logged out and in again. But on whatever page I go URL segment is simply NOT working! How can you check if $input->urlSegment1 suppose to be working or not? $selects = $pages->find("template=child-template, provincie={$input->urlSegment1}"); // this don't work $selects = $pages->find("template=child-template, provincie={$page->title}"); // this works, but I do not think it's good this way.
  13. Before your replied I already changed it to : $select as $child because I thought this could be an issue. Had to change that in my reply above, sorry
  14. yes, just double checked. It's crazy. This thing is keeping me going for the last two days...
  15. Deleted all code and started over... Now, on the 'provincie.php' (which is the template for the children) that makes up the value for my 'parent/child/' pages I tried again. But I was unable to GET the $input->urlSegment1 value. This for some reason would not get the value: $select = $pages->find("template=child-template, provincie={$input->urlSegment1}"); Starting with this at the top of the page also not: $myvalue = $input->urlSegment1; echo $myvalue; But when I just use: $select = $pages->find("template=child-template, provincie={$page->title}"); foreach ($select as $page) { // do my thing everything seems to be working fine.... hope this is good practise?!
  16. Somehow I overlooked the link in the very bottom of this wiki page that leads to this one: http://wiki.processwire.com/index.php/URL_Segments_in_category_tree_example (See also the post above this one) Code is this: if($input->urlSegment1){ //get the post $post = $pages->get("/$input->urlSegment1/"); if(!$post->id) throw new Wire404Exception(); echo $post->render(); }else{ include("./head.inc"); $category = $page->id; $posts = $pages->find("template=child-template, provincie=$category"); echo "<ul>"; foreach ($posts as $post) { echo "<li><a href='{$post->url}'>{$post->title}</a></li>"; } echo "</ul>"; include("./foot.inc"); } But this only solves the first 'provincie' name. Any other just give me no contents.
  17. EDIT --- solved partially, (see also post below) --- My page tree looks like this : ------------------------------------------------ parent - child 1 // item details inclusive custom field name as a link - child 2 // item details inclusive custom field name as a link etc parent has parent-template.php - displays all childs - child url : http://host/parent/itemtitle child has child-template.php - displays a child - url: http://host/parent/itemtitle ------------------------------------------------ provincie // hidden page - custom field - page select - child 1 - child 2 etc Provincie has select-template - without file - template is used site-wide for all page selects : * that way I have 1 template for multiple url segments ! Child has provincie-template.php. *: Branche is a parent page like Provincie, and is using the same select-template. Branche children use branche-template.php ------------------------------------------------ My parent/child url is: http://host/parent/child3 - where child in this case is the item name. My custom field url is: http://host/provincie/child1 - where child in this case is the provincie name. After clicking the custom field link, I get to the 'provincie' page (provincie-template.php) where it GET the url segment '/child1/' and then displays a list for similar items. See post below for code used in provincie-template.php
  18. I hate to ask this, but since I started building I just have to... My pages are like this: Parentpage (template = parent-template) - child1 (template = child-template) - child2 (template = child-template) - etc My parentpage is actually my main page for a list of childs. On certain fileds from those childs in that list I want to have a link that basically give me back a new filtered list of childs with that field value. My link is like this: <a href='{$pages->find("template=child-template, provincie=$child->provincie")}'>{$child->provincie->title}</a> but hovering displays only 'host/parentpage' If I do it like this: <a href='{$pages->find("provincie=$child->provincie")}'>{$child->provincie->title}</a> hovering displays this: 'host/parentpage/ID|ID' I might be missing the concept here, but I thought a link on any field would make an automatich search and displays the childs... What exactly do I need to do? Is there maybe some search page available? And is there a certain search url I have to use?
  19. Okay, thanks for explaining that. For the file from Horst, if possible I'd rather stay out of PW core (updating PW might overwrite this file again) - or is Ryan considering this to be integrated in future?
  20. Just installed Thumbnails module. Although I am not really sure the code for this cropped image 'thumbnail' is good in the template (looking at the colors presented in sublime) But I did get thumbnails back with this code: src='{$child->image->getThumb('thumbnail')}' In the module description it said image->(qe)....etc. Which one is correct? And, is there a native PW way of making cropped images, without a module? Then I also got back blurred images... I followed the link to ImageSizer.USM.php - but I have no clue what to do with it. Include it? Install it somehow?
  21. Thanks, I take all advise and now started to build. Just a few things and expanding bit by bit verrryyyyy slow.
  22. and in the template file probably also change : trunc($child->body,$length); to trunc($child->body,180); // what you said before...
  23. I changed the code from martijn a litle because it did not let through a string that was shorter then what was set in trunc($child->body,180). It works for me, but I am not totally convinced about the two } at the end. Anyway... Code function: function trunc($string, $length) { $length = 180; //modify for desired width if (strlen($string) > $length) { return substr($string, 0, strpos(wordwrap($string, $length), "\n")); } else { return($string); } } Code in template $child can be a $page: trunc($child->body,$length); echo "<div>"{trunc($child->body,$length)}"</div>" did not work for me. But echo with dots instead of brackets did?!
  24. I understand what you say adrian (and others), and I really appreciate all answers. But here's the thing: I started to build - but did not know: everybody say 'play with the code'. I started to play - and try to learn: everybody say 'build'. Now, the only reason I ask Pete to change the topic title is so it's clear to everyone - I am learning - instead of having my name popup all over the forum categories (because my topic should go in an appropriate place). Meanwhile, since the start of this topic it was not clear to me why for instance some kinda function would output the name/value, but with other fields it did not. So by learning about fields I found out why: $allfields = $page->fields; foreach ($allfields as $myfield) echo $myfield; Output: title, body, branche, provincie All the Fields assigned to this page (via it's template). Using echo $myfield->title I thought 'why do not all echo out? I only get back from fields 'branche' and 'provincie'. So what kinda types are there? 'Going one step further I used: $allfields = $page->fields; foreach ($allfields as $myfield) echo $myfield->type; ->type which by the way I could not find on the cheatsheet! Output: FieldtypePageTitle, FieldtypeTextarea, FieldtypePage, FieldtypePage Looking at those fieldtypes it also made sence to me: My $field already represents $page->title, $page->body, $page->branche, and $page->provincie. It has no meaning to do something like: $myfield->title which would be translated as $page->title->title! So, yes - I can build, but I keep learning, looking at the logic before taking your time with questions I should know the answer of. I don't want to know all, but need to know more before I'm building. And mind you, it's more fun learning this way because I get to practice PW and PHP at the same time!
  25. Gives me a lot of garbled code, but still does not really answer my question...
×
×
  • Create New...