HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Using Tempcode Symbols

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#35703 (In Topic #8049)
Joe
Avatar

Honoured member

I'm a bit confused on how the entire Tempcode-symbols system works. I'm trying to make a little block of information (not an actual block, though), and I included the {REMAINING} Tempcode symbol, which is used in the POINTS_PAGE.tpl template. I'm guessing the symbol gets the users point-count, but what I don't understand is, why doesn't this symbol work on the frontpage, yet it works on the points page?

Sort of the same thing for language entries – if I add the {!COUNT_POINTS_LEFT} symbol to the frontpage, I get a "language entry is missing" error, yet again, this symbol works on the points page, but not on the frontpage.

I'm thinking ocPortal only uses language files when it has to. It doesn't actually search in all the language files… it only uses the corresponding language file for the page you're viewing. Am I correct? This block of information I'm making is highly essential, so I really need to be able to use symbols like this. As for the language entries, would it be safe to add the {!COUNT_POINTS_LEFT} entry to the global language file (I'm thinking this will make it work)? If this can be done, how do I go about doing this for the Tempcode symbols?

Back to the top
 
Posted
Rating:
#35717
Avatar

I'm a bit confused on how the entire Tempcode-symbols system works.

The one you identified is a 'parameter' rather than a symbol, and parameters are passed into templates by the code specifically for that template.

Symbols start '$' (like lang strings start '!'). I think there might be a 'POINTS_LEFT' symbol. {$POINTS_LEFT} – they're all listed in the Tempcode tutorial.

Am I correct?

Yes.

would it be safe to

Yes.



Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • 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 ocPortal whenever you see the opportunity.
  • 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 ocPortal 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.
Back to the top
 
Posted
Rating:
#35720
Joe
Avatar

Honoured member

Aha. Thanks Chris. :)

Back to the top
 
Posted
Rating:
#35739
Joe
Avatar

Honoured member

I don't think there is a {$POINTS_LEFT} symbol. I tried using it, but it doesn't display anything; it's just blank as if I never put anything in the Comcode page.

I just took a peek at the Tempcode documentation, and the only entry that pertains to 'points' is the IS_ON_POINTS symbol. I looked in symbols.php as well, and the only one I came across was also the IS_ON_POINTS symbol. :/

Back to the top
 
Posted
Rating:
#35780
Avatar

Yeah, sorry, I got confused - we added this to 4, and I gave an example of how to add it to 3 somewhere on this forum.
To do it, add this code into sources/symbols.php inbetween any of the similar looking chunks of code (which make up most of the file)…

Code

         case 'AVAILABLE_POINTS':
            if (get_option('is_on_points')=='1')
            {
               require_code('points');
               $value=available_points(array_key_exists(0,$param)?intval($param[0]):get_member());
            }
            break;

This creates the AVAILABLE_POINTS symbol.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • 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 ocPortal whenever you see the opportunity.
  • 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 ocPortal 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.
Back to the top
 
Posted
Rating:
#35787
Joe
Avatar

Honoured member

Parse error: syntax error, unexpected $end in /home/public_html/sources/symbols.php on line 1

Back to the top
 
Posted
Rating:
#35795
Joe
Avatar

Honoured member

Well, it works, just not exactly as I thought it would. :P

I have somewhere around 300,000 points on my site, and this symbol shows my point-count without a comma (300000). Is there any way I can add this?

Back to the top
 
Posted
Rating:
#35798
Avatar

Yeah…

Code

         case 'AVAILABLE_POINTS':
            if (get_option('is_on_points')=='1')
            {
               require_code('points');
               $value=number_format(available_points(array_key_exists(0,$param))?intval($param[0]):get_member());
            }
            break;

As for the line-break problem (PP-ed to me), perhaps try uploading in the FTP program's binary mode?


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • 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 ocPortal whenever you see the opportunity.
  • 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 ocPortal 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.
Back to the top
 
Posted
Rating:
#35803
Joe
Avatar

Honoured member

It's set for automatic. I'm not too familiar with the transfer modes as I've never had to experiment with them, but doesn't 'automatic' upload actual files in binary mode, and uploads images in ASCII?

Anyhow, thanks. :)

Back to the top
 
Posted
Rating:
#35805
Avatar

Text (including PHP code) would be in ASCII. But I think the issue is that a text transfer can involve changes made based on line-ending assumptions.

To be honest, I think 'Text' mode is an anachronism. Nowadays we have Unix format text files on Windows, and Windows format text files on Windows, and cross-platform software - so FTP software trying to convert during transfer is just going to needlessly cause trouble.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • 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 ocPortal whenever you see the opportunity.
  • 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 ocPortal 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.
Back to the top
 
Posted
Rating:
#35827
Joe
Avatar

Honoured member

Aha. See how bad I am? I got them mixed up. :P

Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: