Viewing 8 replies - 1 through 8 (of 8 total)
  • Fabulous, just what I wanted to hear. Keep the comments coming. good or bad and I will make changes to suit.

    thanks
    Sean

    Hi again, after looking at your site I thought I would remind you that you can use [sb_parent] on each child page like I have on my boat website. It privides a back link so that your users can get back up the tree if need be. Look at the articles section on https://boathook.sean-barton.co.uk then look at the top and bottom of wach child page.

    hope it helps
    thanks
    Sean

    Hi Sean,

    Thanks for this great plugin, it’s really great and very helpfull. I’m currently using it as a directory listing ??

    I wanted to ask you if it was possible to list child-pages in 2 columns instead of just 1 column. If so, what do I need to change or will you be releasing a new version with this option?

    Thanks again,

    -David

    Hi David,

    The layout of the child pages is kind of up to you because its fully templated. However I can maybe add the option or write a template for you to put it in two columns.

    The simplest way to do it would be to use divs instead of a unordered list so the start and end would be <div> and </div> with the list items being <div style=”width: 49% float: left;”>list item hook here</div>.

    You may need to add a clearing div at the bottom or use overflow: auto; in the containing divs style to do it but it should work fine.

    Let me know if it doesn’t make sense and maybe I can talk to you via IM or email to get a better idea of what you are after.

    thanks
    Sean

    Hi Sean, the plugin is working great for me on 2.7. I’m trying to make child pages link with their Custom Field instead of the Page Title, as in grab the ‘Link’ Custom Field contents and use that for each link title.

    How hard do you think that would be? ??

    Thanks, Dan.

    Hi Dan, It should be easy enough to do. Open the plugin PHP file and look for line 69 (68 is if($p)…)

    Paste in the following code:

    $custom_fields = get_post_custom($p->ID);
    $link = (isset($custom_fields[‘link’]) ? $custom_fields[‘link’]:$p->guid);
    if ($link) {
    $link = array_pop($link);
    }

    Then change 73 from the following:

    $template = str_replace(‘[post_permalink]’, $p->guid, $template);

    to:

    $template = str_replace(‘[post_permalink]’, $link, $template);

    Then assuming you did it correctly the [post_permalink] template placeholder will then link them to the ‘link’ custom field instead of the post permalink.

    I would have gotten back to you sooner but for some reason this forum has no email notification for favourite posts. I do check the thread most days though if ever you need help.

    thanks
    Sean

    Hi, thanks Sean ??

    I actually managed to figure it out in the end through trial and error, I ended up with:

    foreach ($children as $i=>$child) {
    if ($child->post_type == ‘post’) {
    $p = get_post($child->ID);
    $linktitle = get_post_meta($child->ID, ‘Link’, $single = true);
    } else if ($child->post_type == ‘page’) {
    $p = get_page($child->ID);

    $linktitle = get_post_meta($child->ID, ‘Link’, $single = true);

    }

    if ($p) {
    $return .= $settings->child_list_loop_start;
    $template = $settings->child_list_loop_content;
    $template = str_replace(‘[post_title]’, $linktitle, $template);

    Not elegant, but it works ??

    Hi Dan,

    Yes as long as it works it should be fine but a couple of stylistic changes I recommend you make:

    Firstly move the $linktitle = … lines out of the if statement at the top and into the if ($ip)…. part lower down seeing as its unnecessarily duplicated code where it stands.

    Secondly I think you may have coped the function definition from the codex because the $single = true is invalid for a function call. It just needs to read true instead. See my following block of code:

    foreach ($children as $i=>$child) {
    if ($child->post_type == ‘post’) {
    $p = get_post($child->ID);
    } else if ($child->post_type == ‘page’) {
    $p = get_page($child->ID);
    }

    if ($p) {
    $linktitle = get_post_meta($p->ID, ‘Link’, true);
    $return .= $settings->child_list_loop_start;
    $template = $settings->child_list_loop_content;
    $template = str_replace(‘[post_title]’, $linktitle, $template);

    Just me being picky but it does make for an easier to maintain system in the long run ??

    Let me know if I can help you or anyone further. I am keen to see how and where people are using it.

    thanks
    Sean

    ps: also using your method if there is no link custom field then the post title will be blank ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: SB Child List] Does the trick’ is closed to new replies.