Page 1 of 1

CGContentUtils call the value and key/label separately

Posted: Mon Jan 15, 2018 5:17 pm
by howey
Hi

I have set up CGContentUtils and configured a radio button list

1080 x 1920|1
1920 x 1080|2
1280 x 1024|2
1920 x 540|4
540 x 1920|5

I am using the value of the radio button to display the appropriate aspect ratio

Code: Select all

{content_module module='CGContentUtils' block='tft_resolution' label="Display resolution" tab="TFT Specification" assign="tft_res"}

{if $tft_res == '1'}<p>9:16</p>
{elseif $tft_res == '2'}<p>16:9</p>
{elseif $tft_res == '3'}<p>4:3</p>
{elseif $tft_res == '4'}<p>32:9</p>
{elseif $tft_res == '5'}<p>9:32</p>
 {/if}
How can I display the resolution ie 1920 x 1080. If I just add the assigned variable

Code: Select all

{$tft_res}
I get the value ie "2".

I assume it's being able to call the key/label. But I've tried variations to know avail.

Thanks in advance for the help.

Re: CGContentUtils call the value and key/label separately

Posted: Tue Jan 16, 2018 2:35 pm
by PinkElephant
howey wrote:If I just add the assigned variable

Code: Select all

{$tft_res}
I get the value ie "2".
I'm not sure I understand the issue -- if you've got the value '2', there's no scope issue, and what you posted...

Code: Select all

   {if     $tft_res == '1'} 9:16
   {elseif $tft_res == '2'} 16:9
   {elseif $tft_res == '3'} 4:3 
   {elseif $tft_res == '4'} 32:9
   {elseif $tft_res == '5'} 9:32
   {else} [unspecified] 
   {/if}
... should work. Or is something else going on? Maybe the '1280 x 1024' value typo...
howey wrote:

Code: Select all

1920 x 1080|2
1280 x 1024|2
?

Re: CGContentUtils call the value and key/label separately

Posted: Tue Jan 16, 2018 2:49 pm
by howey
I probably didn't explain properly.

With the line item in the drop down being

Code: Select all

1920 x 1080|2
I can test the value

Code: Select all

{if $tft_res == '2'}16:9{/if}
But if I then want to display the screen resolution 1920 x 1080, how do I show this value rather than the value '2'

ie if I just use

Code: Select all

{$tft_res}
then I get '2" displayed, where I want to display 1920 x 1080

Still not sure if I've explained it right. Basically I want to access and display the item either side of the pipe divider separately.

I could just use

Code: Select all

{if $tft_res == '2'}1920 x 1080{/if}
But this means a bit more code than accessing the item directly.

Thanks

Re: CGContentUtils call the value and key/label separately

Posted: Tue Jan 16, 2018 3:20 pm
by PinkElephant
howey wrote:I could just use

Code: Select all

{if $tft_res == '2'}1920 x 1080{/if}
Ah, sorry - that's what I meant to post (not the aspect ratio summaries)
howey wrote:But this means a bit more code than accessing the item directly.
I'm not sure if the mechanism can deliver key/value pairs but maybe you'd prefer to populate the option values with literals (one per line, no pipe-value required)...

Code: Select all

1080 x 1920
1920 x 1080
1280 x 1024
1920 x 540
540 x 1920

Re: CGContentUtils call the value and key/label separately

Posted: Tue Jan 16, 2018 3:26 pm
by howey
Hi

I think you are right, I'm probably over complicating the function.

If I stick to

Code: Select all

1920 x 1080
Without the pipe, I can test against the single item ie

Code: Select all

{if $tft_res == '1920 x 1080'}16:9{/if}
Then there's no additional code to call the value 1920 x 1080.

Thanks, just being able to ask the question has clarified my thought process.