Adding Trademark Symbol For Specific Taglines


I’d like to add a registered trademark symbol to a specific tagline so that it appears recursively across several pages. How can I best approach this? An example:

Wheaties- Breakfast of Champions

I’m thinking of changing config.php so it is like this:

c::set('wheaties- breakfast of champions', 'Wheaties- Breakfast of Champions®');

But when I make that change, nothing happens. I don’t want to have to go to every individual template to individually add that registered trademark symbol- I want it to appear whenever that tagline is present. Is there a simple way to do this?


In which way is the tag line represented in your templates at the moment? As plain text?

Check out the docs on kirbytext pre & post filters. You could use them to automatically append the ® symbol any time that slogan appears on a page. near the bottom is an example.

@sakamies I had thought about those filters as well, but do they work on something that is hard-coded into the template as it seems to be the case?

Oh, right, if it’s in the template and not in the content, then probably no. A shell script that reads the templates and replaces those strings might work? If you need to do it just occasionally, maybe a find & replace operation accross the template files would be the simplest way to go.

Exactly, in fact, I would put the tagline into a content file (site.txt) and then find and replace the hard coded tagline with a reference to $site->tagline(), so that you don’t have to touch the templates every time you change the tagline. After all, that’s why you use a CMS in the first place.

Thanks, @sakamies and @texnixe! I ended up using a combo of both of your recommendations, as there are some instances where the tagline is hard coded in the site, and then others when a panel user will be entering the tagline in the panel itself. Not quite ideal as there are two elements to change (site.php and config.php) every time the tagline is changed…

Is there an easy way to invoke the $site->tagline() value in kirbytext? That would solve this whole issue much more gracefully.

Here’s the general idea:
The tagline value is set in site.php.
A panel user enters {{tagline}} in kirbytext as part of the content for a page.
In config.php, the c::set variable is set to refer to the <php echo $site–>tagline() ?> value.

Is this line of thought possible?

Making your own kirbytag is easy, what you’re thinking of should be easy peasy to make by modifying the first example in the docs.

Replace the line return '<a href="">Wikipedia</a>; with something like return $site->tagline();

Can’t remember off the top of my head if tags have the $site variable available, but you can get to it through kirby()->site() too if I’m not mistaken.

When you’re done, your users can do (tagline: ) to output the tagline. Or if you want another syntax like {{tagline}}, you could try those post filters.

I don’t think you need to set the tagline in the config at all if you make a kirbytag and use $site->tagline() in your templates.

Simply put the following code into site/tags/tagline:


kirbytext::$tags['tagline'] = array(
  'html' => function($tag) {
    return site()->tagline();

Your users can then use (tagline:) in the Kirbytext content and the tagline gets inserted.
If you have multiple taglines, the following could work:


kirbytext::$tags['tagline'] = array(
  'html' => function($tag) {
    // Default value
    if(!$tag) $tag = 'default';
    // Add a prefix
    $field = 'tagline-' . $tag;
    return site()->$field();

(tagline:) would now use the site field tagline-default, but (tagline: another) would use tagline-another.

1 Like