You can add query string or another argument to the link of article, for example:
node/[nid]/magazine or node/[nid]?ct=magazine
node/[nid]/book or node/[nid]?ct=book
After that you need to add visibility to the Book and Magazine block that appears in sidebar.
For Book block:
node/*/book
For Magazine block:
node/*/magazine
Hope it will help.
P.S. You can add argument or query string to the link of article through template_preprocess_node function by changing $vars['node_url'].
P.P.S. Just figured out that you can only use new argument, not query string.