Jump to content

How to filter by radio buttons or checkboxes values (page fields) and get the results via (sub-)links?


Christophe
 Share

Recommended Posts

@fbg13,

I think I've found the source of the problem. I made a big mistake. I've learned my lesson. 

Logically, civilite should only have one value. At one moment I had allowed the field to contain several pages (I think I wasn't sure it was only for the API and not also for the admin). 

(I had had a similar problem at one moment with another radio button (page) field on the persons pages where, when changing the color of the eyes, the new color would be added instead of the old choice being replaced.
I had converted this field from a checkboxes (page) one to a radio buttons (page) one.)

I've had this confirmation by changing the value for some "key" pages, with several pages allowed and with only one allowed for the field, and seeing the differences in 3 different versions of the sql file made with DB Backup. Easy with Sublime Text (but I'm currently using Linux Mint's default text editor to write code, I like the back and forward buttons...).

And I had cloned a lot of pages to quickly have several pages for the tests.

So, I made one or two silly mistakes...

I hope I can resolve this quickly by saving again all the pages.

I'll come back to confirm.

Edit: apparently, once it is stored, it stays there. So pages that already have more than one value keep the other values.
I guess I'll just have to remove the pages having this issue. I don't want to mess with/edit the sql file.

Edit2: after saving again, both men (that were cloned women initially) had the value of Mademoiselle, and the women that were displayed in the Men page (that were cloned women that had had at least once the value of Monsieur saved) had the value of Monsieur.
I've changed all this, saved and now everything is working.

I still have the other filtering system to figure out, but now I have more chance of being able to make it work.
And this one was a little more "mandatory" than the other one.

Thanks again (a lot)! I've learned a lot!

Link to comment
Share on other sites

<?php include('./_head.php'); // include header markup ?>

		<!-- main content -->
		<div id='content'>

      <?php           
      if($input->urlSegment1 == $woman) {        
        $filter = ", civilite=mademoiselle|madame";        
      }       
      if($input->urlSegment1 == $man) {        
        $filter = ", civilite=monsieur";        
      }
      ?>	        

      <div id="directory_listing" class="row">
        <div class="grid-fourth margin-top">      
        <?php include('./_left_menu.php'); ?>
        </div>

			  <div class="grid-three-fourths row">        
        <?php  
        echo "<h1>" . $title . "&nbsp;<span>" . $gender . "</span></h1>";     
        $children = $page->children("limit=12{$filter}");
        $pagination = $children->renderPager();	
        foreach($children as $child) { 
					  $thumb = $child->joindre_au_maximum_4_photos->first()->size(200,200);				
					  echo "<div><a href='$child->url'><img src='$thumb->url' width='$thumb->width' height='$thumb->height' /></a><p><strong><em>$child->votre_pseudo</em></strong><br />$child->pays</p></div>";
			  }
        echo $pagination;	
			  ?>	
       </div>
      </div>
		</div>

<?php include('./_foot.php'); // include footer markup ?>

 

Edited by Christophe
Link to comment
Share on other sites

Here is the code for Autres Artistes:

<?php include('./_head.php'); // include header markup ?>

		<!-- main content -->
		<div id='content'>

        <div id="directory_listing" class="row">
        <div class="grid-fourth margin-top">      
        <?php include('./_left_menu.php'); ?>
        </div>

			  <div class="grid-three-fourths row">        
        <?php  
        echo "<h1>" . $title . "&nbsp;<span>" . $skill_title . "</span></h1>";     
        $children = $page->children("limit=12{$filter}");
        $pagination = $children->renderPager();	
        if($children->count) {
          foreach($children as $child) {          
		        $thumb = $child->joindre_au_maximum_4_photos->first()->size(200,200);				
		        echo "<div><a href='$child->url'><img src='$thumb->url' width='$thumb->width' height='$thumb->height' /></a><p><strong><em>$child->votre_pseudo</em></strong><br />$child->pays</p></div>";
          }
        }
        else {
          echo __("Pas de ") . $skill_title . __(" pour le moment.");
        }			  
        echo $pagination;	
			  ?>	
       </div>
      </div>
		</div>

<?php include('./_foot.php'); // include footer markup ?>

Some variables are in _init.php now:

// Gender variables
$woman = __("femme");
$man = __("homme");
$gender = "";
$filter = "";            
if($input->urlSegment1 == $woman) {
  $gender = $woman;          
}       
if($input->urlSegment1 == $man) {
  $gender = $man;        
}    

// Skill variable
$choix_autre_artiste = $pages->get(1069);
$filter2 = "";     
  foreach($choix_autre_artiste->children('include=hidden') as $skill) {      
    if($input->urlSegment1 == $skill->name) {  
      $skill_title = $skill->title;      
      $filter2 = ", qui_2=$skill->name";                  
    }
  }

I've updated the left menu code in the post where it was displayed.

Thanks a lot again @fbg13 for your help and for introducing me to url segments. 
I knew they existed but it's the first time I'm using them.

Edited by Christophe
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...