This is my first question on StackOverflow. I tried to post a comment in a message Can the Joomla module “know”? what position is he in? but could not find any way to do this, so I have to ask one more question here. Any advice on how to do this properly is very welcome. Anyway, here are my questions:
I tried the code mentioned in the above post, but it didn't seem to work. I'm not only new to PHP, but also coding, so I'm not sure if it is me or the code. Here is what I did with the default.php file:
1) so that I paste the code in the right place, I insert
<?php echo(print_r($module)); ?>
and he outputs 1 in the correct position;
2) the position name that I need to determine is "showcase-a", so I am inserting the code
<?php if ($module->position == 'showcase-a'):?>test<?php endif;?>
to the indicated location, but this time he does not show anything;
3), I tried this code:
<?php if ($module):?><span>test</span><?php endif; ?>
But still he does not display the “test” in the position, as I expected.
4) I tried
<?php if (1):?><span>test</span><?php endif; ?>
and the test "test" is displayed as good. Therefore, I did not formulate the IF statement incorrectly.
Now I am completely lost. Since print_r ($ module) outputs 1, the $ module must be positive, why does PHP ignore the test in 3)? This is just a side issue for learning PHP. What I still need to decide is to let the module determine what position it is in. Please help. Thanks!