MysteryStyle Posted April 14, 2009 Share Posted April 14, 2009 I am working on a website within Joomla. There is a search for the entire website. I want to create one page that has specific terminology, a list of terms and their definitions. I would like a dedicated search JUST for the list of terms. For example, a user can visit this page and search for a term within the list and see the definition. Please help! Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/ Share on other sites More sharing options...
Maq Posted April 14, 2009 Share Posted April 14, 2009 Yes this is possible. What part are you having trouble with? Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-810049 Share on other sites More sharing options...
MysteryStyle Posted April 14, 2009 Author Share Posted April 14, 2009 I have hired a web developer to create the website. He says he does not know how to do this. I am looking for code or some type of guidance to give to him to make this possible. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-810142 Share on other sites More sharing options...
mrMarcus Posted April 14, 2009 Share Posted April 14, 2009 just create a table in your db, name it 'terminology'?, have the contents outputted to your page, and when a user want to search what he/she sees, they are just searching the 'terminology' table. or something like that. if your developer (proficient coder) can't come up with that, he's not ready to be charging for his work. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-810144 Share on other sites More sharing options...
jackpf Posted April 14, 2009 Share Posted April 14, 2009 He doesn't sound like a very good web developer. If you have a table with all the terms, you can just do something like this: $word = $_POST['word']; $sql = mysql_query("SELECT * FROM table_definitions WHERE word LIKE '%$word%'"); while($fetch = mysql_fetch_array($sql)) { echo '<span style="font-wieght: bold;">'.$fetch['word'].'</span><br />'.$fetch['definition'].'<br /><br />'; } Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-810145 Share on other sites More sharing options...
MysteryStyle Posted April 15, 2009 Author Share Posted April 15, 2009 Thanks for the responses. I forwarded the information to my web developer. He said: "This is not what your looking for this just does a regular site search, it isnt ideal for page searching." Is there something more specific and ideal for searching within this one page? Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-810376 Share on other sites More sharing options...
gizmola Posted April 15, 2009 Share Posted April 15, 2009 I'm not sure what to suggest. Seems like this calls for a joomla module to be written. The Module should include a form at the top that executes the custom search for users. The approach outlined of having a that has the terms and definitions seems fine to me. Assuming mysql, you could utilize it's fulltext index feature. You can get an idea of what is possible by looking at this site http://www.movie-gurus.com/ When you do a search in the box, it utilizes a mysql fulltext index. Put in a phrase like sky world and you'll get a whole range of titles that match either of the words in the phrase. The behavior can be controlled in a variety of ways. For something that involves words and definitions, using a fulltext index could be an excellent solution, and willl perform well, even if you end up with a large number of definitions. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-810381 Share on other sites More sharing options...
.josh Posted April 15, 2009 Share Posted April 15, 2009 You said you have a page of terminologies -> definitions. Like a dictionary, right? And you want to be able to type in "bat" and it returns all the entries that have "bat" somewhere in the term and/or definition, right? So you are wanting something like www.dictionary.com, except with your own words/definitions, right? Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-810405 Share on other sites More sharing options...
MysteryStyle Posted April 15, 2009 Author Share Posted April 15, 2009 You said you have a page of terminologies -> definitions. Like a dictionary, right? And you want to be able to type in "bat" and it returns all the entries that have "bat" somewhere in the term and/or definition, right? So you are wanting something like www.dictionary.com, except with your own words/definitions, right? Crayon, this is absolutely correct. They key is I need the search for "bat" to be different then the entire site search. The entire site search is already there and works perfectly. I would like a search for the list of the terminology to be dedicated ONLY to that list so if a user goes to the terminology page, they can find the term they are looking for without wading through search results of the entire website. Does that make sense? Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-810988 Share on other sites More sharing options...
.josh Posted April 15, 2009 Share Posted April 15, 2009 okay well basically you would have a column in your table that flags what things you want to be listed in the search and then add that filter to the query jack suggested. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-810998 Share on other sites More sharing options...
MysteryStyle Posted April 16, 2009 Author Share Posted April 16, 2009 I forwarded this information to my web developer. He said that it can't be done in php using mysql it has to be done using javascript/Ajax. Is there any information or resources available to make this happen? Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811122 Share on other sites More sharing options...
.josh Posted April 16, 2009 Share Posted April 16, 2009 the only thing javascript/ajax would be useful for is doing some kind of live/realtime interactive search. Like, dynamically showing narrowed down results as you type in a word sort of thing. It sounds to me like your web developer is trying to blow smoke up your ass because he has no clue how to do even basic server-side scripting. I suggest you find another web developer. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811124 Share on other sites More sharing options...
premiso Posted April 16, 2009 Share Posted April 16, 2009 It sounds like you need a new web developer. You do not need ajax, it would just require a page reload for the filter, as CV suggested. If you do not want a page reload, that is your preference and AJAX would be required, but where do you think AJAX would be getting it's information from? PHP and MySQL. It sounds to me that the developer just does not know PHP/MySQL and is trying to back out of this job or learning the proper method. You can do this with flat files, but you are already using joomla (which I have never used) you might as well use MySQL as it will be quicker and better in the long run. As stated you are getting fed crap from this developer, either they do not know what they are doing or do not want to do it. Honestly, it sounds like an easy thing to do, as jack has showed. You have a table with the terms and definitions then an input field on a form use that with the MySQL Like clause to find the term and viola. You have the definition. Honestly it would/should take less than an hour to actually code (not including the methodology/structure of the sql). If you want it as a joomla module, it may take longer depending on how much knowledge of that system you/your developer have. This is just my opinion. Jack's example above seems to be exactly what you were looking for. You will need to create a terminology table, as suggested, and add the terms/definitions to it. That will not search the whole site, it will only search that table as it should be defined that way in the query. Where your developer is coming with that searching the whole site, I have no clue. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811128 Share on other sites More sharing options...
MysteryStyle Posted April 16, 2009 Author Share Posted April 16, 2009 Thanks for the responses. It is very much appreciated. I spoke with my web developer and I think the problem is on my end describing what exactly we want. When it was mentioned that it would be like "dictionary.com", this is not fully correct. The terms will on be on one page, almost like long list of terms and definitions. This is obviously different than dictionary.com where every word is on a different page. Sorry for the confusion, I didn't realize at the time that dictionary.com isn't exactly what I want to do because the words and definitions will be on the same page. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811137 Share on other sites More sharing options...
.josh Posted April 16, 2009 Share Posted April 16, 2009 so...you don't actually have any terms or definitions stored in a database anywhere...it's just hardcoded on a page? If that is the case, then yes, you can conceivably use just javascript to search the page. It really depends on how your page is marked up, as to how easy it would be to search the page, though. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811138 Share on other sites More sharing options...
xtopolis Posted April 16, 2009 Share Posted April 16, 2009 Sounds like you want a "FAQ" type page with <a> anchors to jump to the definitions. If you imagine it as this: Page loads, has ALL of the keyword - definitions (likely in alphabetical order) display on screen at once. Users can search for a word instead of having to scroll down. Then it can likely be done with javascript only. You could store the keywords - definitions in a database, making them easy to manage and have it echo out the contents when the page loads. Then you could do several things, like having at the top a list of the Alphabet, so if they click "C" it jumps to the beginning of the C section (using an <a> anchor link). Then, for those users who don't know how to use CTRL + F on their browser, you could also include a search bar at the top that uses javascript (or AJAX if you wanted) to see if a term exists, and jump to , or load the definition. This could be handled many cool ways, such as using a live suggestion thing. (fyi, dictionary.com uses the same page for most words, it just loads new content into the same template, the content being stored in its database) edit: CV beat me, but I typed it all out, so too bad. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811139 Share on other sites More sharing options...
MysteryStyle Posted April 16, 2009 Author Share Posted April 16, 2009 so...you don't actually have any terms or definitions stored in a database anywhere...it's just hardcoded on a page? If that is the case, then yes, you can conceivably use just javascript to search the page. It really depends on how your page is marked up, as to how easy it would be to search the page, though. Crayon, I gave your question to my web developer, he said: "it technically is stored in the database but its not really an option to search the database plus its better to do it in javascript since its more like cntrl f u cant search the database because the way its layed out its within the entry in the table for the page its in so itll give u back the page it doesnt have its OWN entry" Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811145 Share on other sites More sharing options...
.josh Posted April 16, 2009 Share Posted April 16, 2009 so basically he's saying that all the terms and definitions are in the database, but as a single cell that stores the page as a whole. well if that's the case, there won't really be any benefit to searching with a query or with php. Unless the page is totally crap marked up. Then I'd suggest using php just because it has more powerful regex capabilities. But javascript probably would be the best bet, again, depending on how it's marked up, since it can target elements. Also to make the search more "flashy" if that gets you off. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811152 Share on other sites More sharing options...
MysteryStyle Posted April 16, 2009 Author Share Posted April 16, 2009 Sounds like you want a "FAQ" type page with <a> anchors to jump to the definitions. If you imagine it as this: Page loads, has ALL of the keyword - definitions (likely in alphabetical order) display on screen at once. Users can search for a word instead of having to scroll down. Then it can likely be done with javascript only. You could store the keywords - definitions in a database, making them easy to manage and have it echo out the contents when the page loads. Then you could do several things, like having at the top a list of the Alphabet, so if they click "C" it jumps to the beginning of the C section (using an <a> anchor link). Then, for those users who don't know how to use CTRL + F on their browser, you could also include a search bar at the top that uses javascript (or AJAX if you wanted) to see if a term exists, and jump to , or load the definition. This could be handled many cool ways, such as using a live suggestion thing. (fyi, dictionary.com uses the same page for most words, it just loads new content into the same template, the content being stored in its database) edit: CV beat me, but I typed it all out, so too bad. Xtopolis, thanks so much for your answer. I believe we can use the letter anchor idea as a worst case. For the javascript/ajax search, is there something out there that can produce the control+f effect, exactly how you described, for users who don't know how to use it. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811157 Share on other sites More sharing options...
MysteryStyle Posted April 16, 2009 Author Share Posted April 16, 2009 so basically he's saying that all the terms and definitions are in the database, but as a single cell that stores the page as a whole. well if that's the case, there won't really be any benefit to searching with a query or with php. Unless the page is totally crap marked up. Then I'd suggest using php just because it has more powerful regex capabilities. But javascript probably would be the best bet, again, depending on how it's marked up, since it can target elements. Also to make the search more "flashy" if that gets you off. So using javascript, what specifically can my web developer use to create this search? Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811159 Share on other sites More sharing options...
.josh Posted April 16, 2009 Share Posted April 16, 2009 If you're wanting to mimic the ctrl+f, don't reinvent the wheel. Simply write a message on the screen instructing users to press ctrl+f and how to use it. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811160 Share on other sites More sharing options...
MysteryStyle Posted April 16, 2009 Author Share Posted April 16, 2009 If you're wanting to mimic the ctrl+f, don't reinvent the wheel. Simply write a message on the screen instructing users to press ctrl+f and how to use it. Ideally, the page could do something similar to the letter anchor and bring you down to the word instead of highlighting it. Also, important: cntrl+F would highlight every word, this could cause it to highlight words that in the definitions and not just the words I want to define. For example, if I have: bat - a wooden object base - [definition] wooden - [definition] And the user types wooden in control+f, then he will get the first definition (of bat) instead of getting the word he wants the definition for. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811165 Share on other sites More sharing options...
.josh Posted April 16, 2009 Share Posted April 16, 2009 okay well path of least resistance would be for you to go and hardcode anchor tags around all of your terms, including an id, and when user enters in a word, use some js regex to find the closest matching id and jump to that anchor tag. that is, get the innerHTML of the anchor (using the id), and regexing for a closest match. Or I guess you could just have your id be the same as the term. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811168 Share on other sites More sharing options...
jackpf Posted April 16, 2009 Share Posted April 16, 2009 Hmm...I'm not actually sure if this is the best method. If you're serious about doing this, and you're going to have hundreds/thousands of words/definitions, this page will take like 2 minutes to load. If you were to do it with PHP/MySQL, you could only load the relevant/searched results. Just a suggestion. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811292 Share on other sites More sharing options...
.josh Posted April 16, 2009 Share Posted April 16, 2009 well I definitely agree that the better method would be to put your terms and definitions into a database, but it's sounding like nobody wants to go through that effort, so we're exploring the best alternative. Quote Link to comment https://forums.phpfreaks.com/topic/154099-is-this-possible-with-php/#findComment-811651 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.