Filter Advanced Class Question ;)

More
14 years 6 months ago #17818 by ViveLeFlexicontent
Hello dear flexicontent friends,

I have a wish I would like to see realized and am wondering how to get it done..

- I want to change the code so when someone selects a filter option it will open in a new window and the filter will be added to the url name.

- or better yet: static pages for the seperate filter options/selections, and leave the normal filter page as it is.

So if there were 10 filter options like colors.
I would like a seperate though dynamically created page.
If allthecolors/ = parent and has the filter options
then allthecolors/red = child which only shows the red ones, and doesn't have the filter option, and so on for the other 9.

Now how to do this..

Am thinking myself of adding code like: window.open(url); and target="_blank" do you guys think this would work? Or anyone have an idea on how to go about this..

Please help, this would make my day(s)

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

More
14 years 6 months ago #17850 by ggppdk
If you do it with:
window.open(url);
you will have to write javascript code, to append to url all form field data normally sent be POST method.

Maybe this would be better:

1.One NEW configuration parameter to any field for adding custom html tag parameters when field acts as a filter, and
2. Then inside this new configuration parameter we could write:

onchange='this.form.target="_blank"; this.form.submit();"
and
onchange='this.form.target="_self"; this.form.submit();"

for all other field when they act as filters.

OR to make it more simple to the user but less powerful, we could add a new radio configuration parameter for the field "Where to submit filtering form" with options:
a. same page
b. new page


But this is too advance to show to average users and confuse them. Not sure thinking ...


-- 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 review. Thanks!

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

More
14 years 6 months ago #17865 by ViveLeFlexicontent
thanks you so much for your thoughts on this. will give it a try and do some tests tomorrow, and let you know how it went.
I really want to do this for seo purposes, and having allot of extra pages wont hurt either :mrgreen:
thanks, have a great weekend :!:

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

More
14 years 6 months ago #17867 by ggppdk
You think you know what code to change, i did not say what files need changing for this, because i was just thinking.

Do you really need this ? why not same page?

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 review. Thanks!

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

More
14 years 6 months ago #17868 by ViveLeFlexicontent
yeah I think it's the in code in the blog template, category-items.php am I correct?
well as I have 200+ filter options for one field, and they are very important to my site, if I have separate pages for them I can give each page its own meta title, meta description. Which will be a big plus.
Back end code:
Code:
<?php if ((($this->params->get('use_filters', 0)) && $this->filters) || ($this->params->get('use_search')) || ($this->params->get('show_alpha', 1))) : ?> <form action="<?php echo $this->action; ?>" method="post" id="adminForm"> <?php if ((($this->params->get('use_filters', 0)) && $this->filters) || ($this->params->get('use_search'))) : ?> <div id="fc_filter" class="floattext"> <?php if ($this->params->get('use_search')) : ?> <div class="fc_fleft"> <input type="text" name="filter" id="filter" value="<?php echo $this->lists['filter'];?>" class="text_area" onchange="document.getElementById('adminForm').submit();" /> <button onclick="document.getElementById('adminForm').submit();"><?php echo JText::_( 'FLEXI_GO' ); ?></button> <button onclick="document.getElementById('filter').value='';document.getElementById('adminForm').submit();"><?php echo JText::_( 'FLEXI_RESET' ); ?></button> </div> <?php endif; ?> <?php if (($this->params->get('use_filters', 0)) && $this->filters) : ?> <div class="fc_fright"> <?php /* echo '<span class="filter">'; echo 'Saison: ' . $this->filters['field24']->html; echo '</span>'; */ foreach ($this->filters as $filt) : echo '<span class="filter">'; echo $filt->html; echo '</span>'; endforeach; ?> </div> <?php endif; ?> </div> <?php endif; ?>
Front end code looks like:
Code:
<span class="filter"> <select id="filter_19" onchange="document.getElementById('adminForm').submit();" name="filter_19">

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

More
14 years 6 months ago #17869 by ggppdk
mmm good idea to do it at the the template.

Here it is what to do:
1. if you want all you filters to open in new page the go to the form and put target="_blank":

<form id ="adminForm" ... target="_blank" ...>

2. if you want some of your filters to open in new page and some in same page
Then do a regular expression replace on the html code of your filters:
Code:
// FOR ALL filters you want in new page do: $filt->html = preg_replace('/onchange="[^"]*?"/', "onchange=\"this.form.target='_blank';this.form.submit();\"", $filt->html); // FOR ALL filters you want in same page do: $filt->html = preg_replace('/onchange="[^"]*?"/', "onchange=\"this.form.target='_self';this.form.submit();\"", $filt->html);

Note: you must do both statements as each filter will set the target html parameter of the html form tag ...

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 review. Thanks!

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

More
14 years 6 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
14 years 6 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 review. Thanks!

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

More
14 years 6 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
14 years 6 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 review. Thanks!

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

Moderators: vistamediajoomlacornerggppdk
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
Save