Filter Advanced Class Question ;)

More
12 years 8 months ago #17875 by ViveLeFlexicontent
ah progress :D
it worked so far, at least no errors.
I only used the _blank out of the 2nd code portion you gave me to test it. And it opened in a new window.
back end
Code:
foreach ($this->filters as $filt) : echo '<span class="filter">'; echo $filt->html = preg_replace('/onchange="[^"]*?"/', "onchange=\"this.form.target='_blank';this.form.submit();\"", $filt->html); endforeach;
shoud I have left the
Code:
echo '</span>';
at the end?
front end it showed
Code:
<select onchange="this.form.target='_blank';this.form.submit();" id="filter_19" name="filter_19">
I didn't use both parts of the code as you said I should, because then I should add an if and else statement right?
But in testing this I think I found the proper way to go at this.
It should remain in the same window, but with the filter option id, value, or probably best would be the label added to the url. this type of code perhaps?
Code:
onchange="window.location='index.php?'+this.value"
I just need to be able to save the url in acesef so I can add the metadata. Though maybe I should disable acesef when testing this. Not sure if it will show the parameter when base url is set to used and cache.
Again, thanks a million for the help, really appreciate it, I'm not that good with coding..

edit: in acesef it shows these urls, they have nothing to do with the filters right or do they :roll:
Code:
index.php?option=com_flexicontent&Itemid=106&cid=page%3A58.html&view=category index.php?option=com_flexicontent&Itemid=106&cid=page%3A20.html&view=category index.php?option=com_flexicontent&Itemid=106&cid=page%3A122.html&view=category index.php?option=com_flexicontent&Itemid=106&cid=page%3A106.html&view=category
this is the used/normal one
Code:
index.php?option=com_flexicontent&Itemid=106&cid=36&view=category

Please Log in or Create an account to join the conversation.

More
12 years 8 months ago #17876 by ggppdk
The 2 preg_replace is of course to be put inside an if because as i said, you want some filters to open in new window and some in same window.

Also if you want the new window to be always the same don't use _blank but a name like "mydemoA" as target.

The code is easy to implement do something like:
Code:
$fieldnames_target = array( 'myfieldname1'=>'mydemoA', 'myfieldname2'=>'mydemoA', ..., 'myfieldname5'=>'_self', 'myfieldname6'=>'_self', ..., 'myfieldname9'=>'mydemoB','myfieldname10'=>'mydemoB', ..., ); $default_targ = '_self'; // or anything you want $pattern = '/onchange="[^"]*?"/'; $replacement = "onchange=\"this.form.target='%s';this.form.submit();\""; foreach ($this->filters as $filt) : echo '<span class="filter">'; if (isset($fieldnames_target[$filt->name])) $targ = $fieldnames_target[$filt->name]; else $targ = $default_targ; echo preg_replace( $pattern, sprintf($replacement, $targ), $filt->html ); echo '</span>'; endforeach;


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
12 years 8 months ago #17880 by ViveLeFlexicontent
hmm looks like it renames the filter itself with this code.
the if else worked though, at least it opened in a new window or stayed in the same.

but it didn't add a parameter to the url nor did a new url show up in acesef.

could you tell me where the code is for creating the filter?
so I can try and add code there like this example from stackoverflow site:
Code:
<select name="forma" onchange="window.location='http://<?php echo $this->getUrl(); ?>' + this.options[this.selectedIndex].value + '/';"> <option value="Home">Home</option> <option value="Contact">Contact</option> <option value="Sitemap">Sitemap</option> </select>

Please Log in or Create an account to join the conversation.

More
12 years 8 months ago #17882 by ggppdk
This code is the same as the previous one , only more clean and more complete. I haven't change the code of the regular expression, it would not rename filter unless you changed *? to *.

Temporarily put output both original filter and changed filter html (inside the foreach):
Code:
echo $filt->html; echo preg_replace( $pattern, sprintf($replacement, $targ), $filt->html );

Post here the html code of one the filter to compare ...

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
12 years 8 months ago #17886 by ViveLeFlexicontent
So I just have this code left..
with the echo filt->html line it creates a duplicate of the filters.. so it shows each filter twice in the front end. but only 1 is working, the other one doesn't
Code:
$pattern = '/onchange="[^"]*?"/'; $replacement = "onchange=\"this.form.target='%s';this.form.submit();\""; foreach ($this->filters as $filt) : echo $filt->html; echo preg_replace( $pattern, sprintf($replacement, $targ), $filt->html ); echo '</span>'; endforeach;
without the echo filt->html it works like it normally should but nothing extra.
front end it shows
Code:
<select id="filter_19" onchange="this.form.target='';this.form.submit();" name="filter_19">
Maybe it would be better/easier if I fetch the items with mysql, so I can create seperate pages for the items containing the fields.
Don't know what do you think? Create sql or continue to get this to work..
200+ options per field, and each item belongs to min 1 field and max 200, so per category 200 pages each showing the items seperately.

Please Log in or Create an account to join the conversation.

More
12 years 8 months ago #17888 by ggppdk
I only said to output the original filter SO THAT you will be able to compare the html.

The code i provided will allow you to choose some filters to be submit THE FILTERING form in new window and some other to submit THE FILTERING form in same window.

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.308 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline