Adding a new tempcode symbol...
Posted
#5644
(In Topic #1317)
Standard member

how to do?
Hello,I would like to add a new tempcode symbol sort of like the
Code
{$USER_AGENT}my idea is to create
Code
{$BROWSERLANG} so i can see what is the major language used by the current user.
I learned that the result of
$_SERVER['HTTP_ACCEPT_LANGUAGE']
is not so straight forward, it may say the visitor as a few languages but will rank them… I am looking at ideas about this issue:http - Using the PHP HTTP_ACCEPT_LANGUAGE server variable - Stack Overflow
meanwhile to create my new tempcode symbol I read:
Code Book, part 1b (Further back-end concepts) - Composr
"…
Adding a new symbol, to refer to custom data and functions within templates
To add a new symbol you'll need to write a systems/symbols hook. This is a very useful technique for extending the Tempcode system…."and
Code Book, part 1a (Core back-end programming) - Composr
Another example: symbols
Composr supports 'symbols' in templates, that do special things. An example of a symbol is our MEMBER_PROFILE_LINK symbol, which makes it easy to link to a member's profile screen from a template (often templates are passed member IDs as parameters, so it allows them to work with their parameters in an effective way). But Composr needs to be extendable. Addons must be able to add their own symbols (e.g. maybe an eCommerce addon would need to define a 'BALANCE' symbol to show a member's balance in any arbitrary template), so there are symbol hooks.For performance Composr doesn't use any symbol hooks for any default functionality, but they are available for new addons.
so what I have done is create:
sources/hooks/systems/symbols/BROWSERLANG.php
Code
<?php
class Hook_symbol_BROWSERLANG
{
public function run($param)
{
$value = "test";
return $value;
}
}
note; I do not know what I am doing here, just copied a different one to see if I can get a result…
then in my page using the new tempcode i get this error: A symbol is missing: BROWSERLANG……..
thankyou in advance for any pointers on this. I can figure out the
$_SERVER['HTTP_ACCEPT_LANGUAGE'] stuff later but I am not sure how to create a new tempcode symbol…

———–
Publisher of IronFeather Journal since 1987. Host of KGNU Colorado Radio for 20 years.
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido: Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp
Publisher of IronFeather Journal since 1987. Host of KGNU Colorado Radio for 20 years.
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido: Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp
Posted
Site director

Try emptying the block cache. That as a by-product will flush the persistent cache, which contains a cache of all existent symbols. I suspect you've turned that cache on.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Posted
Standard member

It works! Super cool, excited to make many new tempcode symbols :)
Thank you
———–
Publisher of IronFeather Journal since 1987. Host of KGNU Colorado Radio for 20 years.
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido: Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp
Publisher of IronFeather Journal since 1987. Host of KGNU Colorado Radio for 20 years.
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido: Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp
1 guest and 0 members have just viewed this.

