Skip Navigation

[Resolved] Views in sidebar inconsistent between pages

This support ticket is created 2 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 32 replies, has 3 voices.

Last updated by Shane 2 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#2378953

You want the sidebar links to remain unchanged even if you're on one of the links correct?

Yes

Each book should have in the sidebar: it's author; the other books of the author; all additional book info pages; and where to buy the book. When you click on a More About This Book link, the sidebar should be the same.

#2378987

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christine,

This should now be working.
hidden link

What I did was to change how the view for the sidebar is being filtered. I've set it to always be filtered by the parent value. So whichever child post you're on, the view will filter based on its parent.

Below you can see my modifications.
hidden link

Notice the addition of
wpvprchildof="[wpv-post-id item='@fiction_book-info.parent']"

As well as the view below i've set it to be filtered by a shortcode parameter.

hidden link

Thanks,
Shane

#2379097

Hi Shane
It is working on that book, but take a look at this one. It seems it is pulling in Additional Book Info pages for many books.
hidden link

It is doing the same thing on others. Here's another: hidden link

#2379631

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christine,

I've found the issue. It appears you're nesting too many content templates which may not be necessary because it is causing the [wpv-post-id] shortcode to not get the correct id of the current page.

If you go here
hidden link

You will notice that i've added the view directly to the content template rather than how you had it loading a separate content template just to load the view.

Thanks,
Shane

#2379681
Errant-text.jpg

Several pages I checked looked fine. But this one hidden link has some odd text in that section. I've attached a screenshot. Not sure why this book has the issue and others don't. Very weird.

Perhaps it's a difference between Fiction books and Non-Fiction books which have different post types and content templates.

#2379779

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christine,

These items were left by me in testing to see what ID's are being returned. This is how I discovered that the correct ID's weren't being returned in some cases.

I've removed these now so they should no longer be displaying.

Can you confirm that everything is ok now.

Thanks,
Shane

#2379831

This book is not showing either link: hidden link

When I look at one of the pages it showing that long list again: hidden link

The other additional page also shows the long list: hidden link

#2379851

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christine,

I'm not seeing any long list on the page below.
hidden link

Secondly it appears that your non-fictional listings are using a separate template, again i'm unable to locate the "More About This Book" section for the page below.
hidden link

Its not appearing in the content template below.
hidden link

Thanks,
Shane

#2379885

The list must have been cached so I don't see it any more.

Both fiction and non-fiction additional info pages seem to be both using Template for Additional Book Infos. And in that code it says:
[wpv-post-body view_template="tutorial-single"][/wpv-post-body]

Tutorial Single is a Content Template. Not sure what a View Template is.

I'm stumped! 🙁

#2381473

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christine,

I must admit that the templating structure is a bit confusing for this website with a few redundant templates.

However can you let me know if there is any other content template that would contain the text "More About This Book " other than this one below.
hidden link

Please let me know.
Thanks,
Shane

#2383035

hidden link

hidden link

hidden link

#2383913

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christine,

Unfortunately none of the templates that you've sent mentions the phrase "More About This Book"

Unless we find where this text is coming from then there isn't much else that I can do as it is not coming from this template below.
hidden link

Were you the one who designed this website ?

Thanks,
Shane

#2384121

I did not create the original website. I do understand WordPress but not that familiar with Toolset.

Two things:
There is code in the functions.php starting at line 167 that seems to pertain to these views. I found "More About This Book" and added a character at the end. That character did show up on the front end.

Also -- When I took my initial screenshots -- the More About This Book section looked fine on Mister Owita’s Guide To Gardening but now it doesn't.

Hopefully the functions.php code will help.

#2384933

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christine,

It would appear that this entire section in hardcoded. It would be quite difficult to undo all of this and implement it with Toolset similarly to how the Fiction books work.

Is there a possibility for you to get back in touch with the developer who made this site ?

As they will need to redesign this to make use of the content templates. Currently they are using this function to generate the sidebar.

// getting new view for sorting
function get_view_and_sort() {

	// $atts = array('id' => '$fiction');
	// $post_id_atts = new WPV_wpcf_switch_post_from_attr_id($atts);

	// $parent_id = get_post_meta($postid, '_wpcf_belongs_fiction_id', true);
	// echo '<pre>';
		// echo var_dump( $post_id_atts );
	// echo '</pre>';

	$view = get_view_query_results( 1768 );

	$titles = array();

	$titlesWithLinks = array();

	foreach ( $view as $filtered_post ) {
	    $titles[] = $filtered_post->post_title;
	}

	$sortedTitles = sortTitles($titles);

	foreach ($sortedTitles as $key => $val) {
		$titlesWithLinks[$key][ 'title' ] = $val;
		$titlesWithLinks[$key]['url'] = getPostUrlByTitle($val, $view);

		//TODO: grab URL
	}

	// echo "<pre>";
	// 	echo var_dump($titlesWithLinks);
	// echo "</pre>";

	$getsiteurl = get_site_url();

	$sideLink1 = $titlesWithLinks[0]["url"];
	$sideTitle1 = $titlesWithLinks[0]["title"];
	$sideLink2 = $titlesWithLinks[1]["url"];
	$sideTitle2 = $titlesWithLinks[1]["title"];
	$sideLink3 = $titlesWithLinks[2]["url"];
	$sideTitle3 = $titlesWithLinks[2]["title"];
	$sideLink4 = $titlesWithLinks[3]["url"];
	$sideTitle4 = $titlesWithLinks[3]["title"];
	$sideLink5 = $titlesWithLinks[4]["url"];
	$sideTitle5 = $titlesWithLinks[4]["title"];
	$sideLink6 = $titlesWithLinks[5]["url"];
	$sideTitle6 = $titlesWithLinks[5]["title"];
	$sideLink7 = $titlesWithLinks[6]["url"];
	$sideTitle7 = $titlesWithLinks[6]["title"];
	$sideLink8 = $titlesWithLinks[7]["url"];
	$sideTitle8 = $titlesWithLinks[7]["title"];
	$sideLink9 = $titlesWithLinks[8]["url"];
	$sideTitle9 = $titlesWithLinks[8]["title"];
	$sideLink10 = $titlesWithLinks[9]["url"];
	$sideTitle10 = $titlesWithLinks[9]["title"];
	
	echo '<div class="listlinks-addl-info-left" style="text-align:left;padding-left:10px;display:block;border-top:2px solid #988777;padding-top:7px;margin-top:10px;padding-bottom:10px;">
  	<h5 style="margin-top:10px;margin-bottom:5px;padding-bottom:5px;border-bottom:1px dotted #cfcfcf;">More About This Book</h5>
    <p class="additional-book-info additional-info-left"><ol class="sidebar-sortedlinks">';

		if (!empty($sideLink1)) {
			echo "<li><a href='" . $getsiteurl . '/?post_type=book-info&p=' . $sideLink1 . "'>";
			echo $sideTitle1;
			echo "</a></li>";
		} else {}
		if (!empty($sideLink2)) {
			echo "<li><a href='" . $getsiteurl . '/?post_type=book-info&p=' . $sideLink2 . "'>";
			echo $sideTitle2;
			echo "</a></li>";
		} else {}
		if (!empty($sideLink3)) {
			echo "<li><a href='" . $getsiteurl . '/?post_type=book-info&p=' . $sideLink3 . "'>";
			echo $sideTitle3;
			echo "</a></li>";
		} else {}
		if (!empty($sideLink4)) {
			echo "<li><a href='" . $getsiteurl . '/?post_type=book-info&p=' . $sideLink4 . "'>";
			echo $sideTitle4;
			echo "</a></li>";
		} else {}
		if (!empty($sideLink5)) {
			echo "<li><a href='" . $getsiteurl . '/?post_type=book-info&p=' . $sideLink5 . "'>";
			echo $sideTitle5;
			echo "</a></li>";
		} else {}
		if (!empty($sideLink6)) {
			echo "<li><a href='" . $getsiteurl . '/?post_type=book-info&p=' . $sideLink6 . "'>";
			echo $sideTitle6;
			echo "</a></li>";
		} else {}
		if (!empty($sideLink7)) {
			echo "<li><a href='" . $getsiteurl . '/?post_type=book-info&p=' . $sideLink7 . "'>";
			echo $sideTitle7;
			echo "</a></li>";
		} else {}
		if (!empty($sideLink8)) {
			echo "<li><a href='" . $getsiteurl . '/?post_type=book-info&p=' . $sideLink8 . "'>";
			echo $sideTitle8;
			echo "</a></li>";
		} else {}
		if (!empty($sideLink9)) {
			echo "<li><a href='" . $getsiteurl . '/?post_type=book-info&p=' . $sideLink9 . "'>";
			echo $sideTitle9;
			echo "</a></li>";
		} else {}
		if (!empty($sideLink10)) {
			echo "<li><a href='" . $getsiteurl . '/?post_type=book-info&p=' . $sideLink10 . "'>";
			echo $sideTitle10;
			echo "</a></li>";
		} else {}

		echo '</ol></p></div>';

}

Thanks,
Shane

#2384959

Ok. Can you give me the fixes you made for the fiction books so I can make them on the live site?