Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Cómo pasar variables xml a JS a través de php

Entonces, estoy tratando de conectar mi entrada xml al archivo Javascript a través de php (opcional). Tengo que concatenar la entrada xml con todas las etiquetas h1 de mi sitio. Estoy tratando de evitar javascript en línea.

Este es mi fragmento de php para cargar el archivo js.

 $this->app->getDocument()->getWebAssetManager()->registerAndUseScript('plg_system_headings', 'media/plg_system_headings/js/index.js', [], ['defer' => true]);

Y este es mi fragmento xml:

 <files> <filename plugin="headings">headings.php</filename> </files> <media folder="media" destination="plg_system_headings"> <!--<folder>css</folder>--> <folder>js</folder> </media> <languages> <language tag="en-GB">language/en-GB.plg_system_headings.ini</language> </languages> <config> <fields name="params"> <fieldset name="basic"> <field name="text_input" type="text" label="HEADINGS_TEXT_VS" default="Greetings!!" /> </fieldset> </fields> </config>

ahora quiero que la variable $this->params->get('text_input') se pase en el archivo js. Intenté escribirlo de esta manera pero no puedo acceder a esta variable.

 window.onload = () => { // Display the alert let h1 = document.getElementsByTagName('h1')[0]; h1.innerHTML= h1.concat(" . $this->params->get('text_input') . "); }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!