0
Welcome Guest! Login
0 items Join Now

SOLVED How to include PHP code into header & different body locations?

  • SOLVED How to include PHP code into header & different body locations?

    Posted 6 years 1 month ago
    • Hi

      Gantry 4 was good for this, gantry 5 is not so good.

      I checked the docs at " docs.gantry.org/gantry5/advanced/php-functions " this does not help.
      I also searched stackoverflow and google, also does not help.

      I tried adding custom php using Sourcerer under the "Global Page Settings". While it works for the "After <body>" and "Before </body>" it does not work for the "Custom content" in the "head section" - I can only include static content (which is NOT what I want).

      I need to include and execute custom "<?php ... ?>" code in the "<head> </head>" section depending on a variety of defined parameters (URL passed), ip addresses, hostnames, usernames etc for a variety of joomla gantry v5 templates.
      How can I do this?

      I also figured one way to do this in the body, but it is really akward and rather time consuming using different Jumi modules (one for each location including different PHP includes).
      There must be a better way?

      thanks
    • Last Edit: 6 years 1 month ago by Jobst Schmalenbach. Reason: change to
    • I code, therefore I am.
    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22450
    • Thanks: 2679
    • Web Developer

    Re: SOLVED How to include PHP code into header & different body locations?

    Posted 6 years 1 month ago
  • Re: SOLVED How to include PHP code into header & different body locations?

    Posted 6 years 1 month ago
    • Damir

      I had that page included in the original question ...

      - I read the document
      - I know how to edit the theme.php file
      - I know how to create the class
      - I can understand the twig file syntax

      I still have no idea how to add the code BEFORE the </head> tag.
    • Last Edit: 6 years 1 month ago by Jobst Schmalenbach.
    • I code, therefore I am.
    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22450
    • Thanks: 2679
    • Web Developer

    Re: SOLVED How to include PHP code into header & different body locations?

    Posted 6 years 1 month ago
  • Re: SOLVED How to include PHP code into header & different body locations?

    Posted 6 years 1 month ago
    • Damir

      Yep, that's it.

      You need to ADD this to the documentation of adding php functions with a good example to add section to the "<head> ... </head>" section, it would have saved me lots of head scratching and a post in the forum.

      I read the section "Creating Custom File Overrides", too. But that gets confusing once your half way down the page - now I get it after connecting it to the "add php code" ...

      A good example "Add custom php code to the <head> section" will be a good example for both document sections and will make it easy for anyone to understand.

      Jobst
    • I code, therefore I am.
    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22450
    • Thanks: 2679
    • Web Developer

    Re: SOLVED How to include PHP code into header & different body locations?

    Posted 6 years 1 month ago

Time to create page: 0.054 seconds