Closed quantumJLBass closed 10 years ago
I think you could do this pretty easily as another extension.
Hook into this filter to add you new shortcode options: https://github.com/shazahm1/Connections/blob/0.7.9.3/includes/inc.shortcodes.php#L277
There is already support for a wide range of query vars you can use to create searches. Here's the entire list: https://github.com/shazahm1/Connections/blob/0.7.9.3/includes/class.rewrite.php#L46
What you could do is hook into this filter: https://github.com/shazahm1/Connections/blob/0.7.9.3/includes/inc.shortcodes.php#L316
Check for the query vars and set the attributes for the retrieve accordingly.
Of course you would need to output your form in order to do the search. To do so, hook into this action: https://github.com/shazahm1/Connections/blob/0.7.9.3/includes/inc.shortcodes.php#L368
There's already a handy function to output the category select here: https://github.com/shazahm1/Connections/blob/0.7.9.3/includes/template/class.template-parts.php#L803
You would have to custom roll something for the state and meta. This function will be pretty handy to output the drop down selects for them: https://github.com/shazahm1/Connections/blob/develop/includes/class.html.php#L320
Oh, you wouldn't need to add a landing page option, use this shortcode option: http://connections-pro.com/documentation/connections/shortcodes/shortcode-connections/home_id/
I think that's it ...
Oh, having to purposefully set email->html() was done to match the WordPress core default behavior when using wp_mail directly
I'm not 100% on the "having to purposefully set email->html() was done to match the WordPress core " are you referring to the mass email?
I'll start rolling an extension then, just wanted to make sure that was the way to run. thank you for the help.
I see what you were talking about on the email, yes, I was just noting to my self that I was going to come back and make that optional was all, and same with all that hardcoded parts there.
ok so the "ExpSearch" extension is here https://github.com/jeremyBass/connections-expsearch .. I'll push on it, but I have a side question that I know is going to come up. I know I need to alter the html structure of what is outside of the list loop. I looked to cmap but saw that it's just the card it's self, and didn't locate where that listing would be best to alter at. I'm sure if I dig I'll find it but thought I'd ask since I know it's going to come up here.
I'll report back once I have a first pass of the extension working. thank you - Jeremy
ok I know I am being needy here. I have pushed up my ini code, but as I look through you links, it occurs to me that what I need to do is that on render stop it from putting out anything at all and then output the search form from the extension. I'm not seeing the root action that I'd be doing this from. Am I on the right track here on what you were driving at? thanks again.
Right ... I actually don't have an elegant solution for that. I've been thinking about adding an show_initial_results
or something similarly named option so the shortcode output will stop unless there are query vars to process. I'm not certain how I want to handle that yet, because I want to add a "Search Results" view...
The hacky thing that can be done now is setup the initial query to limit=1
to limit the performance impact of the db and then hook into this filter and return an empty array():
https://github.com/shazahm1/Connections/blob/0.7.9.3/includes/inc.shortcodes.php#L326
Then you have to deal with the no results message. Maybe the simple solution is to simple unhook the action that calls it. I think that would be: `remove_action( 'cn_action_no_results', array( 'cnTemplatePart', 'noResults' ), 10, 2 );
I ran down that path, but then I occurred to me that the form extension does what I'm after but at the cost of a new shortcode, so I pushed down that route as a test.. basically used [connections_search] verse [connections] .. seem like the right way to deal with this? My original logic was injecting a high level mode which as it stands and like you said, there is no action that will let me drop in correctly. I figure for the moment, this may be the easiest way to move forward.
so running this, on the https://github.com/shazahm1/Connections/blob/0.7.9.3/includes/template/class.template-parts.php#L929
$out .= "\n" . '<select class="cn-cat-select" name="' . ( ( $atts['type'] == 'multiselect' ) ? 'cn-cat[]' : 'cn-cat' ) . '"' . ( ( $atts['type'] == 'multiselect' ) ? ' MULTIPLE ' : '' ) . ( ( $atts['type'] == 'multiselect' ) ? '' : ' onchange="this.form.submit()" ' ) . 'data-placeholder="' . esc_attr($atts['default']) . '">';
This is problematic onchange="this.form.submit()"
. IMHO it'd be best if that was optional. I'm going to hack it for the moment, and don't know if you want that marked on the git issue list, but that does cause an issue in using this in the new extension since I would have a few dropdowns to use.
Right, I have that in there because I needed it to provide backward compatibility with all the templates that had a drop down. Best I can do at this point is provide an option to disable it.
I am going to close this as it has been addressed via a sub plugin, currently repo'd at https://github.com/jeremyBass/connections-expsearch.
Hello, I have my mass email sub-plugin working (note the code is still dirty atm) and need to move on, and I was asked to have a search page by category, state, country, add that meta field of "levels" we chatted on all template-able.
First is this something in the plan? If not I must create it and if that is the case, any preferred way? I was, just off the top of my head, thinking that I'd do it as another sub-plugin that would do a short code and a refining search. I code also fork this I guess and add it to the core too, or .. well to sub or not to sub.
My first thought on the short code was
[connections mode='search' fields='{fieldname},{meta-fieldname}' hide_empty=Boolean theme_file="{file relative path to theme}" landing_page="{slug/id}" ]
so for example
[connections mode='search' fields='category,state,meta-levels' hide_empty=true theme_file="connections-serach.php" landing_page="foo-page" ]
and then after clicking submit, on the landing page you would be able to use a normal shortcode, but if not there then it's just done in place. I don't know yet just thinking out load here.
I need to finish out this site soon and I just want to make sure that I have this set up in a way that is updatable. thank you - jeremyBass