<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Shai</span></b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><br>
thanks a lot for your input, it was <u>VERY</u> helpful! after some
messing about with it, here’s what seems to work when I have the “PHP
Mode” checked in “Page specific visibility settings” for configuring
the block:<br>
<br>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><br>
<?php<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>// makes block appear if content type = blog<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>if ((arg(0) == 'node') && is_numeric(arg(1)) &&
!(arg(2))) {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> $thenode = node_load(arg(1));<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> if ($thenode->type == 'blog') {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> return TRUE;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> }<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>//makes block appear if "blog" is in the URL<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>$url = request_uri();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>if (strpos($url, "blog")) {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>return TRUE;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>?><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>----<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#404040'>brendan, fresh-off.com<o:p></o:p></span></b></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#404040'>Creative Direction & Consultation: Web | Print | Brand<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#404040'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#404040'><a href="http://fresh-off.com">http://fresh-off.com</a><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#404040'><a href="mailto:hello@fresh-off.com">hello@fresh-off.com</a><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#404040'>206.328.1067<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
support-bounces@drupal.org [mailto:support-bounces@drupal.org] <b>On Behalf Of </b>Shai
Gluskin<br>
<b>Sent:</b> Monday, November 09, 2009 8:53 AM<br>
<b>To:</b> support@drupal.org<br>
<b>Subject:</b> Re: [support] getting block to show up for specific pages and
specific node type<o:p></o:p></span></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>He Brendan,<br>
<br>
You are on the right track. You just have to add some more php to do another
test. A slight change in the structure is that you need to make a variable for
the display status and then return it only at the end of the whole snippet.
When there is only one test, you can just set the status "True" or
"False" directly with a return statement that is in the chunk of code
as the test itself (that was how your original snippet did it).<br>
<br>
Note that I did NOT test the code, so there definitely could be a type in there.<br>
<br>
I posted it to a pastebin: <a href="http://pastebin.ca/1663597">http://pastebin.ca/1663597</a><br>
<br>
Shai<o:p></o:p></p>
<div>
<blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;
margin-left:4.8pt;margin-right:0in'>
<div>
<div>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b>Hello,
</b><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>I
found a code snippet on <a href="http://drupal.org" target="_blank">drupal.org</a>
that allows a block to be shown only on specific node types when 'Show if the
following PHP code returns TRUE' is checked on the Configure Blocks page:<o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>-----<o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:10.0pt;font-family:"Courier New";color:#0000BB'><?php<br>
</span><span style='font-size:10.0pt;font-family:"Courier New";color:#007700'>if
((</span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000BB'>arg</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#007700'>(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#0000BB'>0</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#007700'>) == </span><span
style='font-size:10.0pt;font-family:"Courier New";color:#DD0000'>'node'</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#007700'>) && </span><span
style='font-size:10.0pt;font-family:"Courier New";color:#0000BB'>is_numeric</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#007700'>(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#0000BB'>arg</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#007700'>(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#0000BB'>1</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#007700'>)) &&
!(</span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000BB'>arg</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#007700'>(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#0000BB'>2</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#007700'>))) {<br>
</span><span style='font-size:10.0pt;font-family:"Courier New";
color:#0000BB'>$thenode </span><span style='font-size:10.0pt;font-family:"Courier New";
color:#007700'>= </span><span style='font-size:10.0pt;font-family:"Courier New";
color:#0000BB'>node_load</span><span style='font-size:10.0pt;font-family:"Courier New";
color:#007700'>(</span><span style='font-size:10.0pt;font-family:"Courier New";
color:#0000BB'>arg</span><span style='font-size:10.0pt;font-family:"Courier New";
color:#007700'>(</span><span style='font-size:10.0pt;font-family:"Courier New";
color:#0000BB'>1</span><span style='font-size:10.0pt;font-family:"Courier New";
color:#007700'>));’<br>
if (</span><span style='font-size:10.0pt;font-family:"Courier New";
color:#0000BB'>$thenode</span><span style='font-size:10.0pt;font-family:"Courier New";
color:#007700'>-></span><span style='font-size:10.0pt;font-family:"Courier New";
color:#0000BB'>type </span><span style='font-size:10.0pt;font-family:"Courier New";
color:#007700'>== </span><span style='font-size:10.0pt;font-family:"Courier New";
color:#DD0000'>'blog'</span><span style='font-size:10.0pt;font-family:"Courier New";
color:#007700'>) {<br>
return </span><span style='font-size:10.0pt;font-family:
"Courier New";color:#0000BB'>TRUE</span><span style='font-size:10.0pt;
font-family:"Courier New";color:#007700'>;<br>
}<br>
}<br>
</span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000BB'>?></span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>-----<o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'><br>
this works great, except for that I’d like the block to show for nodes of
type “blog” <b><u>AND</u></b> also on specific pages – in my
case <a href="http://www.mysite.com/blog" target="_blank">www.mysite.com/blog</a>
which is a view showing a list of blogs. How can I do both? <o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><br>
----<o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span
style='color:#404040'>brendan, <a href="http://fresh-off.com" target="_blank">fresh-off.com</a></span></b><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='color:#404040'>Creative Direction & Consultation: Web | Print |
Brand</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='color:#404040'> </span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='color:#404040'><a href="http://fresh-off.com" target="_blank">http://fresh-off.com</a></span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='color:#404040'><a href="mailto:hello@fresh-off.com" target="_blank">hello@fresh-off.com</a></span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='color:#404040'>206.328.1067</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>
</div>
</div>
<p class=MsoNormal><br>
--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a>
]<o:p></o:p></p>
</blockquote>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>