Jump to content

RyanJ

Members
  • Posts

    207
  • Joined

  • Last visited

Posts posted by RyanJ

  1. Hi Nik,

    I am pulling in multiple content areas on one page. I was trying in minimize my code. My goal based off your diagram is to get the grandchildren of cat1, cat2 and cat3 and limit them to 3.

    Print Cat1 Title

     Loop through 3 grandchilden of Cat1 and print them

    Print Cat2 Title
    Loop through 3 grandchilden of Cat2 and print them

    Print Cat3 Title
    Loop through 3 grandchilden of Cat3 and print them

     I am getting the correct grandchildren for each cat, but the limit part is confusing me. Clear as mud? :).. I also updated my original snippet of code to include the closing div, just forgot to add it when I posted it.

  2. I am using the below to go several levels deep, but when using a select of "limit" or "sort" I am getting strange results. For example, if limit=2 I get five results. If limit=3 I get six results. I am sure I have messed up something.

    Maybe there is a better way?

    $cats = $pages->get("/mypage/")->children;
    // get children of the parent
           foreach ($cats as $cat) {
            $menu .= "<div>";
            $menu .= "<h2 class='titlebg'>$cat->title</h2>";
             if($cat->children) {
    // if they have children
               $menu .= "<ul>";
                foreach($cat->children as $subchild) {
                 foreach ($subchild->children("limit=2, sort=-date,   
           sort=title") as $child) {
               $menu .= "<li><a href='{$child->url}'>$child->title</a></li>";
             }
            }
             $menu .= "</ul>";
         }
             $menu .= "<span><a href='{$cat->url}'>See More</a></span>";
            $menu .= "</div>";
  3. Hi Macrura,

    Thanks for sharing. I think the idea of using a certain lets say date field to append to the url is a great option. I have not dove into modules/hooks yet, but will take your example for your post and see how I can alter to my needs. Any examples though are always appreciated. Also Adrian's module works great adding the id to the url.

    Thanks

  4. Hi Ryan,

    This is from their technical submission guide lines.

    Article URLs. To make sure we only crawl new articles, please make sure your URLs are unique with at least 3 digits, and are permanent.

    I built a client site using WordPress in the past and the client wished to have their articles submitted to Google News. After reading their guidelines, I did not want to change the url structure of the site to include a digit, so I submitted it anyway. Even though I had submitted a news site-map, a month or so later only 1 article had been indexed and it just so happened to contain some digits in the url.

    I changed the structure to contain dates and the next morning their articles were being indexed. I guess it could also depend on the sites authority and other things, but then again Google does what Google wants :)..

  5. I am trying out your module as a solution to my question here and it works great for archiving. Thanks for sharing it.

    I did have one question though. Using your example structure above, I noticed that if the year "2013" page is already created in the tree structure and if you would go to create a new article page under the "News" a new  "2013"  is created and the new article is placed under that page instead of the already created "2013" page.

    News
        - 2013
         -- Article

    I know the logical sense would be to create a new article under the 2013 page, but users may become confused by that. Is there a way to check if an archive date page is already created under its current parent? If so, to place that new article in the already created one, if not then create it?

  6. Thanks for the link SiNNuT. Google specifically looks for the digits in the url in order to list it in their news feed. From what I can tell this module redirects to the clean version url. I could also see as the articles increase having so many redirects would be undesirable. I too agree that it is strange that they require digits, but tested it and they indeed will not list a url if it does not contain digits.

    you could use a hook that hooks after saving the page, then modifies the name attribute.

    Thanks for the tip Wanze. This seems like it could work. I will have to give it a try.

  7. In order to submit articles to Google news, they require the article urls to be "unique" and contain "at least 3 digits". I have spent most of my morning searching through the forums and have not really found a solution. 

    The best one I have ran across I think is the Process Permalink module. From my understanding of it, you can chose custom url's for pages using a specific template. I am assuming this is kinda what wordpress does with custom post types. However, I do not believe it is being maintained and was never submitted to the module Repository. It also does not work with the current version of ProcessWire and throws several errors. I would love to adopt the module, but am not confident in my skills to make it work yet :).

    The Date Archiver is also a possible solution except in this particular case, archiving the articles is not necessary at this point and if a article is not archived, it does not contain the required digits as google request. Also if you only archive by year, then you may run across the issue of a duplicate title.

    This topic is basically requesting the same, but no solution was really offered other then adding dates to the tree structure which is what the Date Archiver does for you automatically which is awesome! Of course to me this is not a viable option at this point. 

    Several other topics which basically all involve archiving which the date archiver does for you and using url segments.
     
     
     
    Maybe the ability to append the page id or created date to the url? Maybe I have thought upon this too long, but any suggestions are appreciated.
  8. I thought I would add my addition to this for a reference as I was just working on a similar situation yesterday.  In my case, I am getting the child of the parent and then the children of the child. 

    $menu = "<section class='group'>";
    //wrap everything up
          $cats = $pages->get("/parent-page/")->children;
    //get the parent children
           foreach ($cats as $cat) {
    //list each child of parent in a div container.
            $menu .= "<div>";
            $menu .= "<h2 class='myclass'>$cat->title</h2>";
             if($cat->children) {
    // check if child has children?
               $menu .= "<ul>";
                foreach($cat->child->children("limit=1") as $subchild) {
    //get children of child in a ul and limit them to 3
               $menu .= "<li><a href='{$subchild->url}'>$subchild->title</a></li>";
             }
             $menu .= "</ul>";
            }
            $menu .= "<span><a href='{$cat->url}'>See More</a></span>";
    // get the child link
            $menu .= "</div>";
           }
          $menu .= "</section>";
          echo $menu;
    
  9. This is awesome Ryan! I actually used your snippet below and modified it to do what I needed and it worked perfectly, Just took me longer to create the temp field :)..

    foreach($mypages as $p) {
        $p->of(false);
        $p->image->description = $p->temp;
        $p->save();
    }
    

    Your above snippet is definitely a time saver and has been added to my library. It works perfectly when I tested it. I just had to modify it slightly to meet my needs.

    I would just like to say your willingness to bend over backwards to assist others in this forum is a true judgement of your character. You and several others go above and beyond to help others learn with examples. One in particular I would like to mention who helped me way beyond my expectations was Nik. Just like you, he took the time to break things down with examples and even explanations. How you both manage to find the time, I do not know. To you, Nik and all the others who help us learn everyday, I thank you sincerely for helping us. I am confident I am speaking for others as well and say that ya'll truly make a difference to those of us following in your paths.

    • Like 8
    • Thanks 1
  10. Hello,

    copied over the old site into the site folder, but I'm still getting the process wire basic  files

    If you copied over your files, they should replace the old files, so you may have a folder permission issue here? That would be my guess for the first error message. 

    The second would lead me to believe something went wrong with your import or check the naming of the field. If in doubt, do a dump and import the database again. Hope this helps a little.

  11. Since the title field creates the page name automatically and represents the url structure of the page, is there a way to define both when importing? When importing, you must declare a title field. My title fields may contain a word with an apostrophe in it.  For example, "it's" when converted to the url would be it-s. The apostrophe is replaced with a hyphen. Is there a way to just trim the apostrophe so the url would be "its"?

    Thank in advance for any suggestions. 

  12. Hi Russell, 

    I am currently using option 1 for a multisite project and it is working out great and is fairly simple to set up. My only question that has arose recently is about the function ProcessWireHostSiteConfig() found in index.config.php. 

    Is there a size limit for this functions array?  How many sites is too many?

     function ProcessWireHostSiteConfig() {
            return array(
    
                     'mydomain.com' => 'site-mydomain',
                     'www.mydomain.com' => 'site-mydomain',
                     'dev.mydomain.com' => 'site-dev',
                     'www.otherdomain.com' => 'site-other',
    
                     '*' => 'site',                );}
    

    I too will soon be on he journey to search for different options on how to share data between sites. Thanks for the module recommendation adrian.

  13. There are many ways to include a widget area in processwire (just one reason why PW rules!). What kinda of widget are you wanting to include into your side bar? I would start off here and it will give you plenty of ideas. Also, look at the default website that comes with processwire when downloaded. It includes a sidebar area and can give you some ideas. 

    Also check out this post here

    http://processwire.com/talk/topic/2028-adding-a-google-plus-widget-to-your-sidebar/?hl=widget

    Hopefully those will get you on your way :)

    • Like 1
  14. @interrobang. I retract my previous statement. You are correct as I was missing an =. Thank you for that  because I would have probably just started everything all over since its a new site. I wont mention how long I have been trying to figure it out.

    I can now declare defeat by the = and take the idiot of the day award :-[.

    I am taking this as a sign to take a break. :)

  15. It's very unlikely such a search would be performed, but i caught it during some testing, so i guess it would be possible. Cache is not enabled and if i understand correctly GET variables are not cached anyway? Requiring the user to limit the search is a great idea though.

    • Like 1
×
×
  • Create New...