I created an external link for J-locate plugin for Joomla that would help show a certain locations I need on the map since there is no way to set a default location through the plugin. It goes something like this: view=jlocate&state=nc&zip=27604&radius=10
I am trying to figure out a way to get rid of the state filter so it doesn't restrict the zipcodes closest location by the states. Is it possible to put multiple states in the external link I made? It would be nice if it works so it filters through all states, i tried putting something like the following: view=jlocate&state=nc&ca&fl&zip=27604&radius=10 so it would go through multiple states but it only selects the first one, so if the zipcode is not in NC, it wouldn't find it.
My goal is to make the map available so anyone can search all states by the zipcode field alone without putting in a state. This will resolve a border line locations that i am facing right now due to the fact that its filtering states.
Thank you in advance for any positive help.
here is the link to the plugin i am using: http://joomlavida.com/jlocate-joomla-store-locator-demo?zip=33761&state=FL
It really depends on the component.
The correct way to pass a list could be an array
&state[]=nc&state[]=va&state[]=nj
but since you want to do without, why not omit it? If it's forced somewhere beyond your control you could still unset() it.
Otherwise in the unlikely scenario that the programmer is not doing server-side sql injection filtering, pass
&state=%
where % is the wildcard for SQL.
Related
I have created a custom page in Wordpress which presents different data based on the query string. So my query string right now looks something like
http://example.com/extcat/?uid=15&src=blog
Now this is not getting picked either by Google's spidering software or by tracking software properly. They are all tracking it as one single page
http://example.com/extcat
without the uid.
What I want is to rewrite the above query in a format like one of these
http://example.com/extcat/uid/15/src/blog
http://example.com/extcat/15/blog
http://example.com/extcat/15/?src=blog
http://example.com/extcat/15/
I don't care which format I use.
I tried using .htaccess and the WordPress api both. Nothing seems to work.
Here is an in-depth article on how to accomplish what you are doing. Basically, you'll need to register your custom query variables so WP can do it's magic using add_rewrite_rule(). It's a long article, but will provide a better answer then I can write. Plus, you'll learn a whole lot!
https://premium.wpmudev.org/blog/building-customized-urls-wordpress/
I'm working on redirecting people if they type a "not really wrong url".
For example I have a good URL http://www.website.com/category/foo-bar-if-bar-foo/.
This one works so if a user enter to my website with it, I can retrieve the article corresponding.
But if someone enter to my website with a not really wrong url like http://www.website.com/category/foo-bar-foo/ because an another website has referenced a wrong url, I should redirect him to the right one instead of having a 404 status code...
So how should I do this? and Most important, should I do this ?
I actually use Eloquent with Laravel 4.2.
Thank you in advance.
EDIT
I was wrong about stackoverflow, thanks for your comment. It uses the unique ID of a post.
EDIT 2
I Looked at SOUNDEX function in SQL, it's really good if there is a small difference like a character or two missing. But if my url is as broken as my example, it's not working anymore obviously. But thanks it's gonna be usefull.
Just thinking off the top of my head, you could create a SQL table (with Full-Text indexing enabled) containing all your paths (it might already exist).
In the event that a 404 is triggered, hijack that and do a MATCH (Full Text Search) and return the path with the highest scoring MATCH (you can also consider using a score threshold to prevent nonsensical matches).
I'm trying to figure out a way to render a resource with a specific tpl based on a template variable(tv) value. here is my use case:
I have setup a modx installation for a basic site with a homepage and a blog (I used the articles add-on). I want to display blog posts on the home page, outside of the articles container. From my experience the easiest way to do this is with getResource. However for this specific project I would like to change the tpl of the getResources results based on whatever the tv value is for each result.
The template variable can be looked at as a "post type". if you choose "text" it would have tplA, if you choose "multimedia" it would have tplB etc...
now based on my research you would use the properties 'tplCondition' and 'conditionalTpls' to achieve this in your getResources call, something like this:
[[getResources?
&tplCondition=`tv.blogPostType`
&conditionalTpls=`{"1":"tplA","2":"tplB","3":"tplC"}`
&tpl=`defaultTpl`
]]
The problem is, this does not seem to work with template variables :( it even says it only uses resource fields in the documentation.....which is a REAL bummer, as i have no idea to pull this off otherwise. Based on my limited knowledge, you can maybe create a snippet or something that does this, But i have no clue.
Does anyone have an elegant solution to this problem?
to sum up what im trying to do, again:
-assign a "post type" to blog posts in my articles container via template variable.
-use the template variable value to set a specific tpl based on that value.
any help is highly appreciated. thanks
EDIT: okay I got a reply on the forums and have come across a"solution" to this.
you can accomplish this with css. in the tpl, you do something like:
<article class="[[+tv.post-type]]">....</article>
this will output the post type selected in the tv as the actual element class used, and you can then use css to give the output different looks based on the tv. its actually so simple im a little embarrased i didnt see it before. In my situation it 100% solves my problem, however if you needed to chasnge html im guessing javascript would need to be involved or another method with php. just leaving this here in case someone needs it!
If you need to do major changes to the html you could still probably solve it with css if you have a nice markup. However if thats not enough i would solve it by using one tpl for the getresources call, and letting that tpl handle the switching. If you could have your TV output the value symbolize the name of the tpl that should be used in each case, your tpl would only need this:
[[$[[+tv.yourtv]]]]
Your tv will be evaluated first, and then it will be processed as a chunk. That way you dont need a nasty switch or if-clause.
This is assumin you want toally different tpls, and not just need to change some small part of the standard tpl, in that case you could still use this tecnique though!
Conditional templates seem to work fine with pdoResources (part of pdoTools). (I have to put "tv." in front of the TV in the tplCondition but not in the other TVs)
James is correct.
[[pdoResources?
&includeTVs=`blogPostType`
&tplCondition=`tv.blogPostType`
&conditionalTpls=`{"1":"tplA","2":"tplB","3":"tplC"}`
&tpl=`defaultTpl`
]]
I was wondering if their was any sort of way to detect a pages genre/category.
Possibly their is a way to find keywords or something?
Unfortunately I don't have any idea so far, so I don't have any code to show you.
But if anybody has any ideas at all, let me know.
Thanks!
EDIT #Nican
Perhaps their is a way to set, let's say 10 category's (Entertainment, Funny, Tech).
Then creating keywords for these category's (Funny = Laughter, Funny, Joke etc).
Then searching through a webpage (maybe using a cUrl) for these keywords and assigning it to the right category.
Hope that makes sense.
What you are talking about is basically what Google Adsense and similar services do, and it's based on analyzing the content of a page and matching it to topics. Generally, this kind of stuff is beyond what you would call simple programming / development and would require significant resources to be invested to get it to work "right".
A basic system might work along the following lines:
Get page content
Get X most commonly used words (omitting stuff like "and" "or" etc.)
Get words used in headings
Assign weights to different words according to a set of factors (is used in heading, is used in more than one paragraph, is used in link anchors)
Match the filtered words against a database of words related to a specific "category"
If cumulative score > treshold, classify site as belonging to category
Rinse and repeat
Folksonomy may be a way of accomplishing what you're looking for:
http://en.wikipedia.org/wiki/Folksonomy
For instance, in Drupal they have a Folksonomy module:
http://drupal.org/node/19697 (Note this module appears to be dead, see http://drupal.org/taxonomy/term/71)
Couple that with a tag cloud generator, and you may get somewhere:
http://drupal.org/project/searchcloud
Plus, a little more complexity may be able to derive mapped relationships to other terms, especially if you control the structure of the tagging options.
http://intranetblog.blogware.com/blog/_archives/2008/5/22/3707044.html
EDIT
In general, the type of system you're trying to build relies on unique word values on a page. So you would need to...
Get unique word values from your content (index values or create a bot to crawl your site)
Remove all words and symbols you can't use (at, the, or, and, etc...)
Count the number of times the unique words appear on the page
Add them to some type of datastore so you can call them based on the relationships you're mapping
If you have a root label system in place, associate those values with the word counts on the page (such as a query or derived table)
This is very general, and there are a number of ways this can be implemented/interpreted. Folksonomies are meant to "crowdsource" much of the effort for you, in a "natural way", as long as you have a user base that will contribute.
I'm writing an app that allows you to filter database results based on Location and Category.
If someone was to search for Liverpool under the Golf category the URI would be /index.php/search/Liverpool/Golf.
Should someone want to search by Location but not category, they would be sent to /index.php/search/Liverpool
However, should someone want to filter only by category they would be unable to use /index.php/search/Golf because that would be caught by the location search.
Is there a best practice way to have /index.php/search/Golf be recognised? Some best practice as to what else to add to the URI to make these two queries distinct? /index.php/search/category/Golf perhaps?
Though that is beginning to show characteristics of /index.php?search&category=Golf which is exactly what I'm trying to avoid.
Try using $this->uri->uri_to_assoc(n)
described here http://codeigniter.com/user_guide/libraries/uri.html (half way down on page)
basically you will structure your url like this:
mysite.com/index.php/search/location/liverpool/category/golf
NOTE: the parameters are optional so you dont have to have both in there all the time. you can just as well do
mysite.com/index.php/search/location/liverpool/
and
mysite.com/index.php/search/category/golf
this way it will return FALSE if the element you are looking for does not exist
It would probably be best to keep your URI segments relavent no matter what they are searching for.
index.php/LOCATION/CATEGORY
If they are not interested in a location then pass a filler to the system:
index.php/anywhere/golf
Then in your code you just check for that specific string of ANYWHERE to determine if they only want to see the activity. I assume that you are going to be redirecting them with either links or forums (and that they aren't typing the URI string themselves) so you should be safe in just passing information that you expect and testing against that.
I use the format suggested by Tom above and then do something along the lines of below to determine the value of the parameters.
$segment_array = $this->uri->segment_array();
$is_location_searched = array_search('location', $segment_array);
if($is_location_searched && $this->uri->segment($is_location_searched +1))
{
$location = $this->uri->segment($is_sorted+1);
}
Have a look at http://lucenebook.com/#/p:solr/s:wiki and click around a bit on the left-hand navigation. Pay close attention to what happens in the url when you do. I really like this scheme for many reasons.
It's SEO-friendly.
"Curious" people can mix/match the urls and it still resolves to a proper search.
It just looks good!
Of course, the trick is really in the code, in how you build the thing. It took me a few weeks to sort it out, but I finally have my own version of that site. Just not ajax based, because I like search engines better than ajax. Ajax don't pay the bills.