Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #697456

    When I open a tex block and edit it, Enfold presents a list of shortcodes that can be picked up within it. I would like to add a new shortcode which inserts the abbreviation html tag on acronyms

    ex.
    <abbr title=”Lorem ipsum”>LOEM</abbr>

    Right now I have to add it on the html text editor, but since it should be used by the client, I can’t ask him to write html everytime. Hence I was thinking of creating an ad hoc shortcode in the same manner of the dropcap letter.

    Where can I find the php file to modifiy? And what would you suggest to do?

    Thanks

    #697825
    #698172

    Thanks Andy I already added the function and I started to write a new shortcode php file for that purpose, taking a hint from the dropcap.php file to understand how it works.

    Not really sure about how implementing: I did some trials but they did not work. I imagine you cannot help me with a bunch of code?

    I’d just like to have a quick shortcut as the one in the image below that adds to the text the <abbr> tag in which I can modify the full title.

    I already modify the css with the following code:

    abbr {
        position: relative;
    }
    abbr:hover::after {
        position: absolute;
        bottom: 100%;
        left: 0%;
        display: block;
        padding: 5px;
        background: rgb(0,102,204);
        color:rgba(255,255,255,1);
        font-size:12px;
        content: attr(title);
        white-space: nowrap;
    }
    

    So that if I add the <abbr> tag manually in the html editor it works. Still it would be nice I could add a shortcut from the Tiny-MCE Editor!

    Thanks

    Elena

    • This reply was modified 8 years, 1 month ago by elenapoliti.
    #698185

    Hi Andy just found the solution. For information to any other user, here the php code to create an ad hoc shortcodes that adds an <abbr> tag to show full text on mouse hover on acronyms

    <?php
    /*it creates an <abbr> tag*/
    
    if ( !class_exists( 'av_abbr' ) )
    {
    	class av_abbr extends aviaShortcodeTemplate
    	{
    			/**
    			 * Create the config array for the shortcode button
    			 */
    			function shortcode_insert_button()
    			{
    				$this->config['name']			= __('Acronym Extension');
    				$this->config['order']			= 100;
    				$this->config['shortcode'] 		= 'av_abbr';
    				$this->config['tooltip'] 	    = __('Creates a full text which appears on mouse over acronyms terms');
    				$this->config['inline'] 	= true;
    				$this->config['tinyMCE']    = array('tiny_always'=>true);
    			}
    
    			/**
    			 * Popup Elements
    			 *
    			 * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
    			 * opens a modal window that allows to edit the element properties
    			 *
    			 * @return void
    			 */
    			function popup_elements()
    			{
    				$this->elements = array(
    					
    					array(
    							"type" 	=> "tab_container", 'nodescription' => true
    						),
    						
    					array(
    							"type" 	=> "tab",
    							"name"  => __("Content" , 'avia_framework'),
    							'nodescription' => true
    						),
    					array(	"name" 	=> __("Acronym", 'avia_framework' ),
    							"desc" 	=> __("This is the acronym.", 'avia_framework' ),
    				            "id" 	=> "acronym",
    				            "type" 	=> "input",
    				            "std" => __("ACR", 'avia_framework' )),
    					
    					array(	"name" 	=> __("Full title", 'avia_framework' ),
    							"desc" 	=> __("This is the text that appears on your acronym.", 'avia_framework' ),
    				            "id" 	=> "title",
    				            "type" 	=> "input",
    				            "std" => __("Full text", 'avia_framework' )),
    					array(
    							"type" 	=> "close_div",
    							'nodescription' => true
    						),
    						
    				);
    
    		}
    
    			/**
    			 * Frontend Shortcode Handler
    			 *
    			 * @param array $atts array of attributes
    			 * @param string $content text within enclosing form of shortcode element
    			 * @param string $shortcodename the shortcode found, when == callback name
    			 * @return string $output returns the modified html string
    			 */
    			function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
    			{
    				$output = "";
    
    				$atts = shortcode_atts(
    						array(	'title'=>'',
    								'acronym' =>'', 
    							), $atts, $this->config['shortcode']);
    				
    
    			
    				$output = '';
    				
    				$output= "<abbr title='".$atts['title']. "'> " . $atts['acronym'] . "</abbr>";
    
    				
    				return $output;
    			}
    
    	}
    }
    
    

    You can close the topic. Thanks

    Elena

    #698359

    Hi Elena!

    Glad you figured it out and thank you for sharing your solution!
    Let us know if you have any other questions or issues :)

    Best regards,
    Yigit

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Modify the shortcodes list in a text block’ is closed to new replies.