if (View::section('search-results')): NO WORKY!

Permalink
WHY NO WORK?! (View::section('profile')) works like a charm.

'search-results' is the name of the Search Results page. Would like to apply a conditional to the Search Results page, but after beating my brains in for the last hour, can't find any info about this.

If view::selection isn't going to work, is there a way I can get this with the CID?

Here's my code:
<?php if (View::section('search-results')): ?>
    <?php echo "<div id='topsearch'>
      <form class='mysearchform' action='"?><?php echo view::url("/search/search-results"); ?><?php echo "'> 
        <input type='text' value='Search' size='20' maxlength='20' name='query' class='topsearchform' />
        <input name='Search' type='submit' value='Search' class='button' /> 
      </form>
      </div><!--/#topsearch--> "
     ?>
  <?php else: ?>
     <?php echo "<div id=\"login\"> 
    <form method=\"POST\" action=\""?><?php echo view::url("/login/do_login/");?><?php echo "\" name=\"login\">
    <input name=\"uName\" type=\"text\" value=\"Member ID\" size=\"20\" maxlength=\"20\" class=\"loginforms\" onblur=\"if (this.value == '') {this.value = 'Member ID';}\"  onfocus=\"if (this.value == 'Member ID') {this.value = '';}\" />
    <input name=\"uPassword\" type=\"password\" value=\"Password\" size=\"20\" maxlength=\"20\" class=\"loginforms\" onblur=\"if (this.value == '') {this.value = 'Password';}\"  onfocus=\"if (this.value == 'Password') {this.value = '';}\" />  <input name=\"Login\" type=\"button\" value=\"Login\" class=\"button\" onclick=\"javascript:document.login.submit()\" />
    </form>
  </div><!--/#login-->


Basically, if you're on the Search-Results page, it loads a search bar, if not, it loads a login bar.

Already applied this to the view.php for Profile, so the code is sound except that I can't figure out the conditional for view::section [search results page]

 
zoinks replied on at Permalink Reply
Oh... is View::selection() just forthe view.php template? I just realized that's probably why it doesn't work for this one... because search-results uses default.php. How can I apply a conditional so I can load a different area for the Search Results page?
zoinks replied on at Permalink Best Answer Reply
Thanks to nickratering on this thread:
http://www.concrete5.org/community/forums/customizing_c5/get-page-n...

I found the CHEAT SHEET:
http://www.concrete5.org/documentation/introduction/cheat-sheet/...

And figured out how to do it TWO DIFFERENT WAYS


if (view::url('members-area/search/search-results')):

OR

$page = Page::getCurrentPage(); //gets name of current page
if ($page = 'search-results'): //if page is Search Results, do something...

Not sure which I like better. First one is 1 line shorter and makes sense, but maybe #2 makes me think more along the lines of PHP logic and less C5 keywordy? There may be other benefits to either option as well, but I don't know what.

Anyway...

version 1:
<?php 
   if (view::url('members-area/search/search-results')): //if page is Search Results, spit out search box 
   ?> 
      <?php echo "<div id='topsearch'>
          <form class='mysearchform' action='"?><?php echo view::url("members-area/search/search-results"); ?><?php echo "'> 
            <input type='text' value='Search' size='20' maxlength='20' name='query' class='topsearchform' />
            <input name='Search' type='submit' value='Search' class='button' /> 
          </form>
          </div><!--/#topsearch--> "
          ?>
  <?php else: //if not Search Results page, spit out the Login box 
  ?>
        <?php echo "<div id=\"login\"> 
        <form method=\"POST\" action=\""?><?php echo view::url("/login/do_login/");?><?php echo "\" name=\"login\">
        <input name=\"uName\" type=\"text\" value=\"Member ID\" size=\"20\" maxlength=\"20\" class=\"loginforms\" onblur=\"if (this.value == '') {this.value = 'Member ID';}\"  onfocus=\"if (this.value == 'Member ID') {this.value = '';}\" />


version 2:
<?php 
   $page = Page::getCurrentPage(); //gets name of current page
   if ($page = 'search-results'): //if page is Search Results, spit out search box 
   ?> 
      <?php echo "<div id='topsearch'>
          <form class='mysearchform' action='"?><?php echo view::url("members-area/search/search-results"); ?><?php echo "'> 
            <input type='text' value='Search' size='20' maxlength='20' name='query' class='topsearchform' />
            <input name='Search' type='submit' value='Search' class='button' /> 
          </form>
          </div><!--/#topsearch--> "
          ?>
  <?php else: //if not Search Results page, spit out the Login box 
  ?>
        <?php echo "<div id=\"login\"> 
        <form method=\"POST\" action=\""?><?php echo view::url("/login/do_login/");?><?php echo "\" name=\"login\">