We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Remove formatting tags from title tag

How Do I?

Stewf's avatar
Stewf
4 posts
6 years ago
Stewf's avatar Stewf

Our blog often references publications, works of art, or other titles which require the <cite> tag in the headline. How can I omit these formatting tags from the automatically generated <title> for the head element of the page?

       
Stewf's avatar
Stewf
4 posts
6 years ago
Stewf's avatar Stewf

I was able to do this with Tag-Stripper.

       
Rob Allen's avatar
Rob Allen
3,105 posts
6 years ago
Rob Allen's avatar Rob Allen

In cases like this I’d always use a different field to replace the normal Title value where necessary.

       
Andrés Molina's avatar
Andrés Molina
50 posts
6 years ago
Andrés Molina's avatar Andrés Molina

if you need the same field for this, can use a custom plugin with php str_replace function

for example

public function replacedata(){
  $this->buscartxt = (ee()->TMPL->fetch_param('buscartxt'))?ee()->TMPL->fetch_param('buscartxt'):0;
  $this->reemplazatxt = (ee()->TMPL->fetch_param('reemplazatxt'))?ee()->TMPL->fetch_param('reemplazatxt'):0;
  $formtag = str_replace($this->buscartxt, $this->reemplazatxt, ee()->TMPL->tagdata);
  
  return  $formtag;
  
 }

and use in your template

<title>{exp:tcdcl_utilities:replacedata buscartxt="<cite>" reemplazatxt="" }{title}{/exp:tcdcl_utilities:getGridValues}</title>

tcdcl_utilities are the name of yur custom Plugin and replacedata the name of function

this replace only open tag cite , but you can custmize the function its only a simple example.

       
Julie Sholes's avatar
Julie Sholes
1 posts
2 years ago
Julie Sholes's avatar Julie Sholes

Update the code to generate a clean and formatted title without the tags. For example, if you are using JavaScript, you can use the replace() method to remove the tags. Here’s an example:

javascript Copy var title = “Your Title with <cite>Formatting”; var cleanTitle = title.replace(/<\/?cite>/gi, ”); document.title = cleanTitle; In the example above, the replace() method is used with a regular expression /<\/?cite>/gi to globally remove and tags from the title variable. The clean title is then assigned to the document.title property.

By modifying the code that generates the <title> tag in this way, you can ensure that the automatically generated title for the <head> element of your blog’s page does not include the <cite> tags. This will result in a clean and properly formatted title that doesn’t interfere with the display or functionality of your uno online blog.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.