Support » Plugin: Explanatory Dictionary » Detect word in themplate files

Viewing 11 replies - 1 through 11 (of 11 total)
  • I’ve achieved that by wrapping my text (<p></p> for example) around
    <?php echo $dictionary->add_explanatory_dictionary_words(<<<HEREDOC ............. ); ?>)
    after having instantiated
    $dictionary = Explanatory_Dictionary::get_instance();

    The problem is that since I’m using php code in my template, I can’t wrap all my html content in one echo $dictionary->add_explanatory_dictionary_words… but need multiple one. Unfortunately, calling multiple times echo $dictionary->add_explanatory_dictionary_words doesn’t work, I can only have the definition of the last word of the page… Not the other ones…

    Could you help me ?
    Thanks

    Plugin Author EXED internet

    (@exed-internet)

    As for now this is a no, it is meant to only show words inside the content of the page.

    Maybe in a future release but I don’t know that for sure yet.

    Hi !

    Thanks, I figure out how to do that, and it works 😉 !

    Have a nice day !

    @cedric.charles

    Hi! I’m having the same issue you were having. Could you please explain to me how you ended up resolving it? Thanks so much!

    Cheers!
    Gabrielle

    Hi @gabums,

    I’ll answer you in 2 hours and a half 🙂 !

    See you !

    Thank you!

    @cedric.charles!

    Do you have a minute to explain what you did yet please???

    Hi @gabums !

    Sorry, I had a lot of work and totally forget this thread. Hopefully you ask it again 😉 !

    To have a lot of template content processed through the plugin :

    1. Let’s say the template is “mytemplate.php”. Create a new PHP file and call it like you want (here I call it “tobetranslated.php”).

    2. Put the PHP of “mytemplate.php” that need to be processed in “tobtranslated.php”.

    3. Replace that content (in “mytemplate.php”) by this piece of code :

    <?php
       			$dictionary = Explanatory_Dictionary::get_instance();
       			$content = load_template_part($template_path, $template_name);
       			echo $dictionary->add_explanatory_dictionary_words($content);
          ?>

    load_template_part($template_path, $template_name) : First argument is the path (folder etc), second argument is the name of the file (here “tobetranslated.php”)

    ATTENTION : everything in “tobetranslated.php” will be processed. So If you have register the word “test” in the admin and you have a HTML class which is class=”test”, the class will be processed and so the HTML will be wrong !

    Tell me if it works 😉

    Have a nice day !
    Cédric

    No worries @cedric! Thanks for your response. 🙂

    So just to be sure I am understanding you correctly. All I need to do is make a copy of “mytemplate.php” and rename it “tobetranslated.php”. Then I take all the content in “mytemplate.php” and replace it with the code you provided? (with correct paths of course)

    Thanks again!

    So i got it working! The way you did it didn’t quite work for me but I was able to utilize some of your code and place it elsewhere. Incase anyone else is trying to do this too, here it is:

    The way my theme template was calling the text was by using

    echo do_shortcode ( $options['stb_content'] );

    I then took that code and added

    echo do_shortcode($dictionary->add_explanatory_dictionary_words ( $options['stb_content'] ));

    Making sure I placed

    $dictionary = Explanatory_Dictionary::get_instance();

    Beforehand.

    Hope that helps someone.

    Thank you @cedric for your help as well!

    Yes it’s exactly the way it works. Unfortunately, you can place the following code only once per page

    $dictionary = Explanatory_Dictionary::get_instance();

    So If you have multiple shortcode, the_content, the_excerpt, etc… To be processed through the plugin, you just put all these codes in an other PHP file and call this template part inside the $dictionary->add_explanatory_dictionary_words code 🙂 !

    Glad I can help 🙂 !

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Detect word in themplate files’ is closed to new replies.