ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How do you display tags in text as text (instead of it being replaced)?

December 12, 2011 6:00am

Subscribe [2]
  • #1 / Dec 12, 2011 6:00am

    MTWIGG

    8 posts

    I am new to Expression Engine and want to make certain that I am programming correctly. I have a plugin which returns some text into a tag. If the text contains ... {site_name} ... then the screen will display the name of the site instead of {site_name} as actual text (which is what I want it to do).

    Is there an ‘official’ way around this. (I realise that it is unlikely anyone would enter this but with all the different tags it is always a possibility that someone could enter something that matches one of them).

    The function is given below (simplified for this post):

    public function userstext()
    {
        $query = "SELECT utext FROM textfield WHERE user_id=" . $_SESSION['user_id'];    
        $results = $this->EE->db->query($query);    
        $utext = $results->row('utext');
        return htmlentities($utext);
    }

    Which is called by…

    Comments: {exp:memberslounge:userstext}

    The calling template is not embedded into another template.

     

  • #2 / Dec 16, 2011 7:29pm

    Rob Allen

    3114 posts

    If you use a standard textarea field you can wrap code with [ code ] tag and it will output as code, eg

    [code]a p tag[ /code ]...
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases