WordPress.org

Ready to get started?Download WordPress

Forums

Content Aware Sidebars
[resolved] Tags influencing sidebars (16 posts)

  1. lernerleben
    Member
    Posted 1 year ago #

    Hi Joachim

    I really like your plugin but I am having issues with multiple sidebars appearing on single posts/pages when only one sidebar should appear (the problem doesn't affect category archive pages). This problem is caused by the addition of tags to a post. I have found a fix but I think it would be better if you could make changes in your plugin. I will explain the problem and also my fix:

    Issue:
    A page for a podcast on football has its own sidebar with single & archive exposure. The "football" category also has its own sidebar with "single & archive" exposure. (please note the podcast and football categories are each top level categories)

    Everything works fine until I start adding tags to the individual posts: if I add "football" as a tag to a podcast post, then the "podcast" sidebar and the "football" sidebar get displayed. If I delete the tag "football", only the "podcast" sidebar is shown.

    It seems that if the category slug (football) and the tag (football) are the same, the sidebar is shown.

    How I fixed it:
    I changed the slug of the category "football" to "football-football" and the problem was solved (please note, the category name was left as "Football"). The tag "football" could stay as it was. I then had to change each category slug so that they were not exactly the same as the tag (generally by adding "-football" after each one).

    Everything works but it would still be great if you could add an option to deselect tags for awareness.

    Thanks for a great plugin. You're a star!

    http://wordpress.org/extend/plugins/content-aware-sidebars/

  2. Joachim Jensen (Intox Studio)
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for the feedback and kind words. I don't feel like a star though ;)

    I have been able to reproduce your problem and have digged into it.
    You are right that if a category slug and a tag slug (or any other taxonomy term slug) are the same, Content Aware Sidebars gets confused.

    The reason for this is that when you create two terms with the same name and slug, WordPress defines them as being the same, i.e. there is only one instance in the wp_terms table. This also means that using IDs to identify terms instead of slugs wouldn't help.

    There are some major UX problems in WordPress about this problem, which you can read more about here:
    http://core.trac.wordpress.org/ticket/5809

    Content Aware Sidebars use this table for term rules, unlike all other rules that are stored in the wp_postmeta table. Moving the data to that table and storing it as %taxonomy%-%term% could solve the problem, but it's just a thought, and it will probably not be done. Not in the near future anyway. I'd rather that it got fixed in the WordPress core, so that all terms will be quantified in the database.

    However, if you don't want to use Content Aware Sidebars for tags, you can insert the following code in /wp-content/plugins/content-aware-sidebars/modules/taxonomy.php line 31 (version 1.1):

    $this->post_taxonomies = get_object_taxonomies(get_post_type());
    	if(($post_tag_key = array_search('post_tag',$this->post_taxonomies)) !== false)
    		unset($this->post_taxonomies[$post_tag_key]);
  3. Joachim Jensen (Intox Studio)
    Member
    Plugin Author

    Posted 1 year ago #

    I just fiddled a bit with the SQL code in taxonomy.php, and I think I have made a fix for the problem. As it i just a quick fix, I will optimize it, test it and check the performance, and if everything is good, it will be part of the next release.

    For now you can use the code snippet above to deactivate tags, or I can send you the fix if you really really need it.

  4. lernerleben
    Member
    Posted 1 year ago #

    Hi Joachim,

    Thanks for the quick response and the fix. I haven't tried it yet but will do so in the next couple of days (we are about to go live with the site). As I wrote, I fixed the issue by renaming the category slug slightly and it worked fine (e.g., instead of "bundesliga", "bundesliga-news") and left the tag as it was (e.g. "bundesliga").

    I am always thankful to plugin designers/programmers because it's like mind-reading. Every time I look for a plugin to do X, someone has already thought of it. Your plugin is more practical for our site for the following reason: all other sidebar manager plugins that I have found do it on a post/page by post/page basis. I need something I can preset so that the people writing the articles don't have to remember to choose the correct sidebar every time they write a post (guaranteed someone will forget). So, in my book, you are a star! ;)

  5. lernerleben
    Member
    Posted 1 year ago #

    Hi Joachim

    Just tried the snippet you sent, inserted at line 31 and it doesn't seem to work. Is there any thing I need to be aware of when inserting the code, such as indentation, and so on?

  6. Joachim Jensen (Intox Studio)
    Member
    Plugin Author

    Posted 1 year ago #

    The snippet only works for singulars and not archive pages. In my fix archive pages are supported too. The snippet ought to work though as it just removes post_tag if it is present.

    I have added the before mentioned quick fix to pastebin here:
    http://pastebin.com/8BV4AA74

    So you just have to take that code and overwrite your current /wp-content/plugins/content-aware-sidebars/modules/taxonomy.php.

    Let me know if this does not solve your problem.

  7. lernerleben
    Member
    Posted 1 year ago #

    Hi Joachim

    Thanks for all your work so far. I am afraid that it didn't work.

    I created 2 categories, 1 called "footie" and the other called "pel droed" and assigned them to the "football" sidebar. I then entered the same terms as tags in the podcast post, one after the other and the end result was that the "football" and the "podcast" sidebars were both displayed.

    I tried starting from scratch (deleting the categories, tags and sidebar assignation) but got the same result. I accept I could have done something wrong.

  8. Joachim Jensen (Intox Studio)
    Member
    Plugin Author

    Posted 1 year ago #

    I cannot reproduce your issue. Are you sure you have applied the fix correctly?

    If so, can you give me the exact settings of your podcast and football sidebars, e.g. in screenshots of the sidebar edit screen.

    What the fix does is that instead of just checking for terms, it splits the terms into groups for each taxonomy and checks them along with that.

  9. lernerleben
    Member
    Posted 1 year ago #

    Hi Joachim,

    I'm really sorry for the headache I'm causing you. I hope it's all in a good cause. I tried it again by creating three new categories and it worked fine in 1 category but caused a double display in the second and third. Here's what I did:

    The sidebar settings for Football:
    http://lernerleben.de/downloads/football-sidebar.jpg
    For podcast:
    http://lernerleben.de/downloads/podcast-sidebar.jpg

    I first created a category called "Footie" (slug "footie") and then assigned it to the category section of the "football" sidebar. I then entered a tag "footie" on the podcast post (assigned the "podcast" sidebar). Everything worked fine. Only the "podcast" sidebar displayed.

    I then deleted the tag "footie" from the post and re-entered it. The tag popped up. I selected it. Everything worked fine. I entered "Footie" with a capital F. Everything fine.

    I then created a new category called "Bundesliga-champions" (slug "bundesliga-champions"), assigned to sidebar, entered the tag in the post and then it displayed the two sidebars</strong.

    I then created a category called "Bundesliga2", assigned it to the football sidebar, entered the tag in the post and then it displayed the two sidebars.

    There is already a category called "Bundesliga" (with the slug "bundesliga-football" and a tag called "Bundesliga"?

    Hope this helps.

  10. lernerleben
    Member
    Posted 1 year ago #

    Sorry about the "bold" text. Something weird happened.

  11. Joachim Jensen (Intox Studio)
    Member
    Plugin Author

    Posted 1 year ago #

    No headache here yet, however it's good to get this kind of feedback to see if the problem is caused by a bug in the plugin.

    I can still not reproduce your issue, though, so it might be easier if I can have a look at the actual query being run. If you are willing, install http://wordpress.org/extend/plugins/debug-queries/, go to the page with the problem, scroll down and look for:

    Call from: require('..\wp-blog-header.php'), wp, WP->main, do_action_ref_array, call_user_func_array, ContentAwareSidebars->replace_sidebar, ContentAwareSidebars->get_sidebars

    It's usually a big query, so it should be easy to find. Then paste the query in here.

    On another note, I noticed a little UI bug on your screenshots. When you check something, a tick should show up like this:
    http://s.wordpress.org/extend/plugins/content-aware-sidebars/screenshot-1.png?r=606700

    Can I ask what browser you are using?

  12. lernerleben
    Member
    Posted 1 year ago #

    Hi Joachim,

    Re: browser - I viewed the site on Safari 6.0 for iMac. I also viewed the site on FireFox for iMac and the green tick wasn't there. Perhaps the solution is re-install CAS manually (swapping out the taxonomy.php file with the one you supplied) and see if that fixes the problem. I originally installed the plugin via WordPress and also recently updated it automatically (with your new admin layout). Didn't notice the issue before but I also didn't look for it.

    We are about to go live with the site and I don't want to do anything that could disrupt that. By making changes to the slugs of the categories, it works, so I'm sort of happy to not rock the boat at the moment. But I'm sure we will get to the bottom of it and I will do what you requested as soon as I can.

    Thanks

  13. Joachim Jensen (Intox Studio)
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for the info, I'll look into it. I have also noticed some inconsistencies with the tick showing up when it shouldn't and vice versa.

    I think we have misunderstood each other regarding the main problem; the fix I have added to this thread should indeed be swapped with the original taxonomy.php manually, I'm sorry if that was not clear. It is not officially a part of the plugin yet, but I am sure that it will be in the next release - I must point out that the current fix is totally harmless to install.

    I fully understand and respect your choice though. Please let me know if you run into more problems.

  14. lernerleben
    Member
    Posted 1 year ago #

    Hi Joachim

    I did actually change the taxonomy.php file that you put on paste bin. Even with the new taxonomy script, the problem was still as I described above. But I promise I will install the debug plugin and do as you said once we have gone live (which might be tonight!).

    Regards

  15. lernerleben
    Member
    Posted 1 year ago #

    Deleted CAS, removed files and re-installed the plugin from WordPress plugin site and it seems to be working fine with no problem now. Did you change the taxonomy file? Or was it just a problem caused by a bad install / bad update?

  16. Joachim Jensen (Intox Studio)
    Member
    Plugin Author

    Posted 1 year ago #

    Great that it works now. I have not released a new version yet that fixes the problem, though, but I think it will come out on monday.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic