D
D
dind2014-08-14 13:03:41
PHP
dind, 2014-08-14 13:03:41

How to correctly set the default value in the input select using foreach?

There is a quick search block as in the screenshot, it is displayed on all pages, but there was a problem, it is necessary that when the user goes to the site.ru/commercial page, then in the selecte immediately by default on this page was Commercial instead of for Sale. I'll do something like
{if $pageName == 'commercial'}select commercial{/if}, but I don't know how to select the default commercial from the list, since the list is displayed using foreach
Screenshots
prntscr.com/4cok85
prntscr.com/4cokao
www.prntscr.com/4cokdr

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander David, 2014-08-14
@alexdevid

<option value="{$name}" {$pageName == $name ? 'selected' : ''}>{$title}</option>

something like this

S
s1dney, 2014-08-14
@s1dney

the most obvious way:
or pre-build selects for different pages

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question