Welcome, Guest
Username: Password: Remember me

TOPIC: limiting select options

limiting select options 12 Jan 2012 05:51 #947

  • mossss
  • mossss's Avatar
  • Offline
  • Premium Member
  • Posts: 100
  • Thank you received: 7
  • Karma: 9
I have a table Icons which has three fields, Category, Value and icon

there are 12 categories, water, light, edible etc...

I then have a filter on another table that offers the user to filter the table on any of these category-values.

what I want to do is to use the category field on the icon table to limit the choice of options with the filter to those within a category.

The code below works, but has to use the value field on the icon table for the test instead of the category field. This means that I have to have the category text within the value field. It works but not nice, also, as this is going to be in three languages it's really not a good way to do it. So, I need to get hold of the value in the category field during the buildoptions function in COMBO.PHP. I know this should be easy, but its driving me a bit crazy.

any hint would be very welcome. Thanks

Also, is this the correct place to be doing this or would there be a more efficient alternative method?


function buildOptions()
	{
		$html =	'';



		$poscat = "";
	
		if(strpos(JText::_($this->nullLabel),"Light")) {
				$poscat = 1;
			}
		elseif (strpos(JText::_($this->nullLabel),"Water")) {
				$poscat = 2;
			}
		elseif (strpos(JText::_($this->nullLabel),"Structure")) {
				$poscat = 3;
			}
		elseif (strpos(JText::_($this->nullLabel),"Type")) {
				$poscat = 4;
			}
		elseif (strpos(JText::_($this->nullLabel),"Bloom")) {
				$poscat = 5;
			}
		elseif (strpos(JText::_($this->nullLabel),"Fruit")) {
				$poscat = 6;
			}
		elseif (strpos(JText::_($this->nullLabel),"Fragrant")) {
				$poscat = 7;
			}
		elseif (strpos(JText::_($this->nullLabel),"Spikey")) {
				$poscat = 8;
			}			
		elseif (strpos(JText::_($this->nullLabel),"evergreen")) {
				$poscat = 9;
			}
		elseif (strpos(JText::_($this->nullLabel),"Propagation")) {
				$poscat = 10;
			}			
		elseif (strpos(JText::_($this->nullLabel),"eatable")) {
				$poscat = 11;
			}
		elseif (strpos(JText::_($this->nullLabel),"use")) {
				$poscat = 12;
			}			
			
								

			
			
		if ($this->list)
		foreach($this->list as $item)
		{



		
		if($poscat ==  "") {		
		
			$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
		}
		elseif($poscat==1)
				{
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"licht");

				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}
		elseif($poscat==2)
				{
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"wasser");

				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}
		elseif($poscat==3)
				{
					
echo $this->dataValue;
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"planzenstruktur");
				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}				
		elseif($poscat==4)
				{
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"typ");

				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}
		elseif($poscat==5)
				{
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"blutezeit");

				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}								
		elseif($poscat==6)
				{
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"fruchtzeit");

				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}
		elseif($poscat==7)
				{
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"duftplanze");

				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}
		elseif($poscat==8)
				{
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"dornen");

				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}
		elseif($poscat==9)
				{
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"blattabwurf");

				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}
		elseif($poscat==10)
				{
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"vermehrung");

				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}
		elseif($poscat==11)
				{
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"essbar");

				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}
		elseif($poscat==12)
				{
				$pos = strpos($this->buildOption($item, $this->listKey, $this->labelKey),"sonstige");

				if($pos === false) {
					}
				else 
					{
					$html .= $this->buildOption($item, $this->listKey, $this->labelKey);
					}
				}																												
				
		}
		return $html;
The administrator has disabled public write access.

Re: limiting select options 12 Jan 2012 09:35 #950

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
I don't think so.
Not in JDom in that way. The less teatments possible in JDom is better. JDom is only a renderer ! It should not do the work of the application layer.
Always keep in mind, that you always should be able to reuse your own customizated JDom. So it shouldn't hold dedicated functionalities for particular component.

To my opinion, try to do quite the same, but in the VIEW.HTML.PHP file.

Prepare 12 filtered arrays with datas coming from from icon table.
Then, dispatch each array list to its combo.

To my opinion,
You can do this creating a new function (in the view file) which filter (PHP code) and create new filtered array based on parameters. You call 12 times this function, and you can even write this call, directly in your template, when you call JDom.

Hope it helps.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: limiting select options 12 Jan 2012 16:17 #956

  • mossss
  • mossss's Avatar
  • Offline
  • Premium Member
  • Posts: 100
  • Thank you received: 7
  • Karma: 9
thanks

suspected that something wasn't quite right.

will work on your suggestions
The administrator has disabled public write access.

Re: limiting select options 13 Jan 2012 10:59 #966

  • mossss
  • mossss's Avatar
  • Offline
  • Premium Member
  • Posts: 100
  • Thank you received: 7
  • Karma: 9
ok, thanks for the hint, got that working now.

Next issue....

I'm trying to display icon images instead, or as well as, the select values. I've got the correct values in place of the text, but the select options appear as blank. Looking at the HTML source, the values show correctly. Is this a jquery UI thing? anyway around it?

also, while playing I discovered a small bug. The height attribute setting on grid images is spelt wrong. It appears as:

task=file&size=80x0&attrs=fit,format:png&path=[DIR_PLANTS_FOTO_A]009.jpg" style="" width="80px" heigth="53.515625px"/></div></a>

(height spelt as heigth)

thanks
The administrator has disabled public write access.
The following user(s) said Thank You: admin

Re: limiting select options 14 Jan 2012 10:23 #978

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Fixed in 1.4.8.

Thanks mosss
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.246 seconds

Get Started