1

I'm trying to customise trac. I'd like to add a small "Useful links" section inside the "action" box when viewing tickets.

I have edited the site.html file in the trac templates directory as documented in on this wiki page as follows:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      py:strip="">

  <fieldset py:match="fieldset[@id='action']" py:attrs="select('@*')" once="true">
    ${select('*|text()')}
    <div>Useful links: <a href="http://dev.peopleperhour.com/trac/pph/search?q=%231234&amp;noquickjump=1&amp;changeset=on">view all ticket changesets</a></div>
  </fieldset>

</html>

The result is I have a handy link to the search page which displays all changesets for ticket #1234. Great... except that the ticket number (i.e. #1234) is currently hardcoded and I need it to be dynamic, i.e. use the ticket number of the current page. I'm guessing there might be a python variable I can use or I might be able to get the ticket number from the url (it is http://www.example.com/trac/myproject/ticket/1234). Anyone know how I can do it?

1 Answer 1

0

The variable I needed was called $ticket.id

Working code in /var/www/trac/myproject/templates/site.html:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      py:strip="">

  <fieldset py:match="fieldset[@id='action']" py:attrs="select('@*')" once="true">

    ${select('*|text()')}

    <div>Useful links: <a href="http://dev.peopleperhour.com:8000/projects/1/stages/1/deployments/new?task=deploy">Deploy to Staging</a>, <a href="http://dev.peo\
pleperhour.com/trac/pph/search?q=%23$ticket.id&amp;noquickjump=1&amp;changeset=on">View all changesets for this ticket</a></div>

  </fieldset>

</html>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .