Note that there are some explanatory texts on larger screens.

plurals
  1. POCan a Joomla module “know” what position it's in? (2)
    primarykey
    data
    text
    <p>This is my very first question at StackOverflow. I was trying to post comment in the post <a href="https://stackoverflow.com/questions/7647730/can-a-joomla-module-know-what-position-its-in?answertab=active#tab-top">Can a Joomla module &quot;know&quot; what position it&#39;s in?</a>, but could find no way to do that so I have to post another question here. Any tips regarding how to do this properly is greatly apprieciated. Anyway, here is my questions:</p> <p>I tried the code mentioned in the above post but it seemed didn't work. I'm not only quite new to PHP, but also coding, so I'm not sure if it's me or the code. here's what I did to the module's default.php file:</p> <p><strong>1)to ensure I insert the code at the right place, I insert</strong></p> <pre><code> &lt;?php echo(print_r($module)); ?&gt; </code></pre> <p>and it output 1 at the right position;</p> <p><strong>2)the position-name that I need to determine is "showcase-a", so I insert code</strong></p> <pre><code> &lt;?php if ($module-&gt;position == 'showcase-a'):?&gt;test&lt;?php endif;?&gt; </code></pre> <p>to the above place, but this time it does't show anything;</p> <p><strong>3)then I tried this code:</strong></p> <pre><code> &lt;?php if ($module):?&gt;&lt;span&gt;test&lt;/span&gt;&lt;?php endif; ?&gt; </code></pre> <p>But still it does't display "test" at the position as I expected.</p> <p><strong>4)I tried</strong></p> <pre><code> &lt;?php if (1):?&gt;&lt;span&gt;test&lt;/span&gt;&lt;?php endif; ?&gt; </code></pre> <p>and the test "test" displays as good. So I didn't code the IF statement wrong. </p> <p>Now I'm totally lost. Since print_r($module) outputs 1, $module must be positive, why PHP ignore test in 3)? This is just a side question for the sake of PHP learning. What I still need to solve is let the module determine which position itself is in. Please help. Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload