Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 18

Discussione: Php dentro javascript

  1. #1

    Php dentro javascript

    Buongiorno io ho un problema di questo tipo:

    devo fare in modo che lo script qui sotto stampi del php,le ho provate in tutti modi ma non riesco a venirne a capo qualcuno mi potrebbe aiutare per favore?

    codice:
    			function insertReadmore2(editor) {
    				var address = <?php echo $address; ?>;
    				var text = <?php echo $text; ?>;
    					jInsertEditorText('{pub}
    <a href=\"\"+address+\"\" title=\"\"+text+\"\">\"+text+\"</a>{/pub}', editor);
    				
    			}
    secondo me l'errore sta qui ma non riesco a capire dove:



    codice:
    ('{pub}
    <a href=\"\"+address+\"\" title=\"\"+text+\"\">\"+text+\"</a>{/pub}', editor);

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    Domanda: fa parte di uno script .js? Se deve contenere anche php, allora rinominalo in .php. Se invece facesse già parte di codice php, controlla l'effettivo output. Lì ad occhio mancano delle virgolette...
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  3. #3
    fa parte di una pagina php ma ho solo estrapolato e postato qui la parte javascript.

  4. #4
    dove mancano le virgolette?

  5. #5
    praticamente in quella parte javascript deve stampare questi .

    codice:
    $address = $params->get('address');
    $text = $params->get('text');

  6. #6
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    Originariamente inviato da TheShark07
    dove mancano le virgolette?
    codice:
    function insertReadmore2(editor) {
    				var address = "<?php echo $address; ?>";
    				var text = "<?php echo $text; ?>";
    					jInsertEditorText('{pub}
    <a href=\"\"+address+\"\" title=\"\"+text+\"\">\"+text+\"</a>{/pub}', editor);
    				
    			}
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  7. #7
    Non funziona nemmeno cosi.

  8. #8
    Utente di HTML.it L'avatar di Ranma2
    Registrato dal
    Mar 2003
    Messaggi
    2,650
    function insertReadmore2(editor) {
    var address = "<?php echo $address; ?>";
    var text = "<?php echo $text; ?>";
    jInsertEditorText('{pub}
    "'+text+'"{/pub}', editor);

    }

  9. #9
    Niente nemmeno cosi

    posto il codice di tutta la pagina.

    codice:
    <?php
    
    
    // no direct access
    defined( '_JEXEC' ) or die( 'Restricted access' );
    
    
    jimport( 'joomla.plugin.plugin' );
    
    
     */#Parametri delle Impostazioni Plugin
    $address = $params->get('address');
    $text = $params->get('text');
    
    class plgButtonReadmore2 extends JPlugin
    {
    	/**
    	 * Constructor
    	function plgButtonReadmore2(& $subject, $config)
    	{
    		parent::__construct($subject, $config);
    	}
    
    	/**
    	 * readmore button
    	 * @return array A two element array of ( imageName, textToInsert )
    	 */
    	function onDisplay($name)
    	{
    		global $mainframe;
    
    		$doc 		=& JFactory::getDocument();
    		$template 	= $mainframe->getTemplate();
    
    		// button is not active in specific content components
    		$getContent = $this->_subject->getContent($name);
    		$present = JText::_('ALREADY EXISTS', true) ;
    		$js = "
    			function insertReadmore2(editor) {
    				var content = $getContent;
    				var address = "<?php echo $address; ?>";
    				var text = "<?php echo $text; ?>";
    
    				jInsertEditorText('{pub}
    "'+text+'"{/pub}', editor);
    
    				
    			}
    			
    			";
    
    		$doc->addScriptDeclaration($js);
    
    		$button = new JObject();
    		$button->set('modal', false);
    		$button->set('onclick', 'insertReadmore2(\''.$name.'\');return false;');
    		$button->set('text', JText::_('Testo Pub'));
    		$button->set('name', 'readmore2');
    		// TODO: The button writer needs to take into account the javascript directive
    		//$button->set('link', 'javascript:void(0)');
    		$button->set('link', '#');
    
    		return $button;
    	}
    }

  10. #10
    Utente di HTML.it L'avatar di Ranma2
    Registrato dal
    Mar 2003
    Messaggi
    2,650
    si ma cosa non funziona?

    te vai del meccanico specificando "non funziona"?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.