1

I'd like to check if the executed php code is within the div called "parent2".

I am working on a joomla html override and i have to put one module on 2 different positions.

If the module is inside of parent2 some different code should be executed inside of the html override.

The only Problem I have right now is, that I don't know how to check the parent id's that surround the php code.

<div id="parent2">
     <div id="parent1">
           <?php
                 echo ; /*id of the second parent. Here would be the php code of the html override*/
           ?>
     </div>
</div>

I want the echo function to print "parent2".

Parent1 and Parent2 are part of the joomla template and inside of parent1 there is a jdoc:include module position.

I really tried to find a solution via google but all i could find was something with DOMDocument and html parsers, which i believe wont help me.

kapantzak
  • 11,610
  • 4
  • 39
  • 61
sezanzeb
  • 816
  • 8
  • 20
  • 2
    You do understand that PHP is a server side language? Once the browser has loaded the page PHP has already finished its job and can no longer interact with the page. – vascowhite May 05 '15 at 12:40
  • yes. I thought that the server might be able to check the parent ids and then send this to the user:
    parent2
    – sezanzeb May 05 '15 at 13:21

1 Answers1

0

This is not possible with PHP as far as I know.

You should consider this particular snippet of PHP will ALWAYS be executed inside parent2 as parent2 is hardcoded in the PHP file.

jde
  • 198
  • 9
  • because i defined two jdoc module positions joomla will create 2 menus that share the same code. – sezanzeb May 05 '15 at 14:23
  • The problem is that PHP is made to output HTML but you can't process HTML that is already in the output. Maybe joomla gives some variables to help you know the context. Try get_defined_vars(); http://php.net/manual/en/function.get-defined-vars.php to see what's available – jde May 05 '15 at 14:27
  • i found that: https://stackoverflow.com/questions/3787669/how-to-get-specific-menu-items-from-joomla. I think i can write a module that creates a new menu with the mainmenu items that looks different. I'll try that. I will also try var_dump(get_defined_vars()); thank you – sezanzeb May 05 '15 at 14:37
  • yes, it worked like that. It was even simpler than that. I just copied the mainmenu module (in ftp), installed it, assigned the mainmenu to it (which is now duplicated), and changed the mainmenumodule2 code so it displays the menu in a different way. – sezanzeb May 05 '15 at 16:56