Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8063455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:02:27+00:00 2026-06-05T11:02:27+00:00

I am trying to add some html code before each tag printed as an

  • 0

I am trying to add some html code before each tag printed as an array element.  

My code:

  $term_links = array();

  foreach ($vars['node']->taxonomy as $term) 
  {
    $term_links[] = l($term->name, 'taxonomy/term/' . $term->tid,
      array(
        'attributes' => array(
          'title' => $term->description
    )));
  }

  $vars['node_terms'] = implode(', ', $term_links);

At the moment the tags are printed seperated by a comma. I would like to add a small image before each tag element using img src="tag.png" How can I do this?

EDIT – My current Code, still not working.

 if (module_exists('taxonomy')) {

$img  = 'some html';
$text = $img . $term->name;
$path = 'taxonomy/term/' . $term->tid;


$term_links = array();
foreach ($vars['node']->taxonomy as $term) {



  $term_links[] = l($text, $path, array(
    'html' => TRUE,
      'attributes' => array(
        'title' => $term->description
    )));
 }
   $vars['node_terms'] = implode(', ', $term_links);
 }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:02:28+00:00Added an answer on June 5, 2026 at 11:02 am

    Dupal’s l() function has an option “html” you can set it to TRUE and use IMG + TITLE as a title.

    Here is the example:

    $img  = '<img src="..." />';
    $text = $img . $term->name;
    $path = 'taxonomy/term/' . $term->tid;
    
    $term_links[] = l($text, $path, array(
      'html'       => TRUE,
      'attributes' => array(
        'title' => $term->description
      )
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add some html after a specific h1 tag. The line
I'm trying to add some HTML formatted text to Word using Office Interop. My
I am trying to add some code to my Spring JSP to display a
I am trying to add some additional html to a div with id slideshow
I am new to JQuery. I am trying to add some code in my
I'm trying to reuse parts of some JQuery code I've used before for another
I'm making Rails 3.1.1 app and trying to add some jQuery code to it.
I need to add some html right after the body tag so like :
I am trying to add some security to my webpage. My webpage page.html has
I have an html table that I am trying to add some animation to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.