Jump to content

Joss

PW-Moderators
  • Posts

    2,862
  • Joined

  • Last visited

  • Days Won

    47

Everything posted by Joss

  1. Joss

    Url Segments

    Oh, me too .... although I am feeling a little silly! ha. Still, new problem posted on general support ....
  2. Okay, I am trying to do something slight silly. (again) I have a file full to the brim with functions. For instance: function getChildCategoriesPosts($page=null) { if(!$page) $page = wire('page'); loads of stuff } When I call that into a page it works fine, as you would expect. Now, the tricky bit. I want to add it to a widget (that is a page with template in its own right) and then add that widget to my main page using a page select field. The trouble is, the function then uses the widget page as its source of inspiration rather than the main page that the widget is rendered into. How can I get the right reference into the function so that when it asks for wire('page') it gets the information from the main page and not the widget page? I am not 100% sure this is actually possible ... Joss
  3. HI Bruno, Just to check. When you look at your directory either on cpanel or filezilla, what is the path to your processwire installation? Is it something like: /home/username/public_html/index.php or is there an additional directory: /home/username/public_html/directory-name/index.php or perhaps /home/username/public_html/processwire/index.php Joss
  4. Hi Bruno A few questions which will help people to help you: Have you installed ProcessWire in the root of your website or in a sub-directory? If a sub-directory, what is it's name? When you installed, did you specify a directory for admin, or did you leave it at the default "processwire?" What server have you installed this on? Is it on your local machine (xampp or wamp or mamp installation) or is it a shared server/vps/dedicated? If it is a shared server or other, do you know if it is an Apache server, another nix based server or is is a Windows server?
  5. Hi Onjegolders Yes, it is one of the things that has frustrated me enormously, particularly in recent years. I know search engine optimisation is important, but so are returning visitors. So much emphasis is now put on hitting keywords that sites are often uncomfortable to read, products described badly, and there is a complete lack of one-to-one communication. Websites, like radio, are only talking to one visitor at a time; there is not a crowd of people looking at the website, there is lots of one persons. Well, with any luck, you will get a client that says, "I want my site to sound like me," and are happy to pay for that. Then you can give me a call with pleasure. Good luck mate.
  6. ha! Mind you, if I start with German and work back to English, the site will be tiny! As a sound engineer I did a lot of multi-lingual dubbing work. A huge amount of it was into French and German. Spoken, German is significantly longer than English (if translated nicely) and with the verb at the end of the sentence, the subject and object would often be reversed. If you had a long sentence, not only was the German too long, but no longer made sense to the picture! We had two particularly wonderful translators, however, that managed to produce perfect fits. Andreas Klatt and the renowned Wolf Kahler. Wolf's voice, especially, was wonderful - he could roll his Rs all the way to lunchtime and still be on the same word! Very nice site, by the way - I forgot to mention that.
  7. Joss

    Url Segments

    Here is a slight alternative way of doing the check. Above I checked to see if the page was part of the URL segments. However, in my particular case, I can check to see if I am viewing a particular type of page. This could be done by checking the template, or in my case, checking the parent, since all my posts go under the same parent. so, rather than if($input->urlSegment1) { I could use: if($page->parent->name == "posts") { The advantage is how ever I link to the page, it always shows the breadcrumb in relation to the category. However, it should be noted that the URL will be the proper url - so within the site, the same page is linked to potentially twice by two different routes.
  8. Oh, dear, have you got a programme that will all the verbs from the end zu bewegen? They always muck me up.
  9. I suppose Pete, myself and the other Britons should start working on the British version of the site. It will be particularly genteel. be full of really obscure references to concepts like "colour" and "through" and take tea breaks between pages...
  10. Joss

    Url Segments

    Just commented the code. Obviously, you don't actually need to create the separate variable $parentName, but it helps to explain it.
  11. Joss

    Url Segments

    I have just wrapped it in an IF <ul class='breadcrumb'> <?php // Check if this page is being accessed using the URL Segment if($input->urlSegment1) { // Find the fake parent, which is actually the value of a page field used as a category selector $parentName = $page->post_category_select; // Take that value and use the standard bread crumb method to find its parents and print them out. foreach($parentName->parents as $parent) { echo "<li><a href='{$parent->url}'>{$parent->title}</a> > </li>"; } // Print out the page that was the value of the category page select field echo "<li><a href='{$parentName->url}'>{$parentName->title}</a> > </li>"; // Print out the title of the page we are looking at echo "<li>{$page->title}</li>"; } else { // If the page being viewed is not the result of a URL segment routine, use the standard way of generating breadcrumbs. foreach($page->parents as $parent) { echo "<li><a href='{$parent->url}'>{$parent->title}</a> > </li>"; } echo "<li>{$page->title}</li>"; } ?></ul> This is the solution I thought about many posts ago, but in my head it sounded really complicated, so I didn't go any further. If I had sat down and worked it out, I would have saved you loads of time. Sorry Diogo! EDIT: Commented the code.
  12. Joss

    Url Segments

    oh RATS!!!! Stupid me!!! That was easy!! $parentName = $page->post_category_select; foreach($parentName->parents as $parent) { echo "<li><a href='{$parent->url}'>{$parent->title}</a> > </li>"; } echo "<li><a href='{$parentName->url}'>{$parentName->title}</a> > </li>"; echo "<li>{$page->title}</li>";
  13. Joss

    Url Segments

    Yeah, which is why I was thinking about doing it the other way round - taking the name of the current page, looking at it's "parent" via its category select field, then find the tree parents of that. I suppose I would have to recurse upwards! Or just curse, which is what I often end up doing....
  14. Joss

    Url Segments

    Okay, I have done a workaround, though I am not going to put this on the wiki - far too specific! Basically, at the head of my category page, within the if($input->urlSegment1) clause, I have added the breadcrumb. Because of the structure of my site, this just appears rather uselessly in the bottom left of my page - but at least it appears! Then, in my header, I have added if(!$input->urlSegment1) to my normal breadcrumbs so they dont appear if I am messing with URL segments. Then I have used JQuery to move my sad little orphaned bread crumb and stick it in the right place. Tatty, but it works! Joss PS: One day, when I feel I know a bit more, I will mess around with has_parents to see if I can find a better way of doing this.
  15. Joss

    Url Segments

    The trouble is they will access them directly - through search, if nowhere else. But also, in my particular case, through other sort options - categories is only one. Also, page structure may vary considerably from category to post - different things in sidebars, or sidebars on different sides ... etc. Might even have different headers and footers, for all I know So, for the wiki, I need to keep this as broad as possible and allow for posts to be accessed in several ways, not just through one category type system.
  16. Joss

    Url Segments

    Yeah, I did that intentionally, so that you dont end up with some template with heads and feet and others without Not a problem, except for the breadcrumbs ... typical!
  17. Joss

    Url Segments

    The trouble is that posts are not always viewed in relation to a category, so they need the header and footer. My only other option is to not render the result, but reproduce the post template within the category template without head and foot. Though that leaves two versions to maintain. The other way, I suppose, is to do the breadcrumb outside of the template markup (alongside the urlsegment markup - though not part of it) and then import the result into the correct position...
  18. Joss

    Url Segments

    I think the problem is about WHERE in the code the breadcrumb code is happening. Because (obviously) it is within the template, and with the post we are rendering the entire template, then it is picking up the page reference from the post template, not the category template,
  19. Joss

    Url Segments

    Yeah, the URL is right, it is the breadcrumb that is wrong. Or rather, the breadcrumb is accurately showing the real path to the post, rather than the fake one we have created for it.
  20. Joss

    Url Segments

    Ah, that is not what I am getting. On the politics category page I am getting: domain.com/news/politics and the breadcrumb home > news (I could add the "politics" with an extra <li> but I haven't added that to your code.) When I click on a post, the url is: domain.com/news/politics/politic-post but the breadcrumb is: Home > Content Management > Posts > Political Post My URL segment code at the top of the category page is: if($input->urlSegment1){ //get the post $post = $pages->get("/content-management/posts/$input->urlSegment1/"); if(!$post->id) throw new Wire404Exception(); echo $post->render(); }else{ Category....
  21. Joss

    Url Segments

    Well, actually it in in my header since it really needs to work through all the site. The trick is to make it work so it follows the false logic imposed by our URL segments. Actually, it gets worse than that. If you search for a post, then click on its link, you are back to square one. So, I suppose the ultimate bread crumb solutions will go something like this: Check if there is a category/page field (or whatever is the relevence for that particular site structure). In my case it would be looking for a value in post_category_select. If the field exists and there is a value, then that value is what we want to be the parent - work your way up the list and print out the breadcrumb trail If no value, then this is not a post, it must be something in the main site tree, so use normal breadcrumb system. That takes away the emphasis from the referring page, and introduces rules that are relevant to the actual viewed page. Maybe adding URL segments to that would not be helpful - or maybe a way. Not sure.
  22. Joss

    Url Segments

    HI Diogo, Still no luck. Remember I am rendering the output from having identified the post. So, I am assuming that once it is being shown in its own template, the post has no knowledge of where it comes from. On that basis, maybe it needs to take the category path with it so that can be added to the breadcrumb?
  23. Joss

    Url Segments

    Ryan okay, that is a neat title for a wiki page! Do you mind if I shorten it a little?? As for the breadcrumbs, the trouble with that is that is assumes a specific template and I am trying to avoid that - as you said, it can become too specific to a particular site. The only reason I though about bread crumbs, is if you are doing this to make your site more logical, there is a very good chance you are using bread crumbs too. So the two do go kind of hand in hand.
  24. Joss

    Url Segments

    Hi Diogo Didn't work. The problem is that as soon as you hit the link, you jump over to the original path
  25. Unfortunately, I am not a graphic designer. However, if you need a serious copywriter and composer with 35 years in advertising...... (and you don't mind a remote worker)
×
×
  • Create New...