How to add search to my static laravel site? - laravel

I'm building my first ever website using laravel 5.2. Right now, I'm only serving static content with a few API requests for things like the current weather. I've never built a website before, but I'm running my own droplet at DO, so there's no shared hosting limitations.
How would I implement a search that allows users to search my site's content from the main screen? Currently there's no interaction on a DB, it's all just Blade/HTML. I want to avoid using Google Custom Search as there should be no ads, and I want to learn along the way.
Please advise.

It depend on the amount of static contents you have in your site. Maybe you could try implementing it the following way.
Create lookup of the views pages with the most relevant keywords
When user search for keyword which match to any of my relevant keywords, I would load the respective view page.
I would store the the lookup in json format. It would be similar to contents with multiple tags on them.
Here, creating json file is going to be tedious and needs to be done manually.

Related

Static vs. dynamic content in docpad system - how to create dynamic content?

DocPad is described as being comparable to other static site generators, but it is also described as being "not limited to static site generation".
I've been browsing the DocPad website and other documentation and haven't yet been able to find anything that seems to explain how to incorporate dynamic content, and what types of limitations may be involved?
As a relative beginner, I am wondering if anyone can help me better understand the methodology whereby dynamic content would be incorporated into DocPad...? e.g. AJAX, and dynamic server-side scripts for doing things like dynamically loading pictures from Flickr into a webpage when a certain tag is clicked...
Thanks.
So there's a few ways DocPad facilitates dynamic content:
Via the regenerateEvery configuration option. This will regenerate your website every so often you specify. This great when combined with plugins like feedr for pulling in data from remote feed sources (like your latest social activity), as well as repocloner which clones out and keeps a git repository up to date inside your project. The benefit of this option is it's really easy to do and provides the illusion of a dynamic website. For instance the Benjamin Lupton Website applies this method to keep it's statistics on the home page, as well as the social data in the sidebar up to date. Every hour it regenerates with the latest information. Making it fast, and also illusively dynamic.
Via the dynamic meta-data property. When set to to true this tells the DocPad server we should re-render that document on each request, rather than just once. This works great inside the Kitchensink Skeleton for search pages and misc forms. This way is most similar to PHP development.
Via the serverExtend event. This event allows you to hook into and extend the DocPad server, allowing you to add extra server-side logic, handling, etc. Common use cases is to add extra routing to your server to handle route aliases, adding form processing such as a contact form, or to add a RESTULful interface for a Backbone.js application. The DocPad Website uses this to add extra routing and a regenerate post-receive hook for the documentation. The NodeChat Skeleton uses this to add the Socket.io server-side logic.
Via the API. This way is the most involved but can be quite rewarding if you just wish for DocPad to be a small part of an existing node.js application. With this, you can create a DocPad instance in your code and interact with it. The grunt-docs grunt task utilises this :)

wordpress plugin making friendly URLs and accessing variables

I've been searching for a couple of days for a particular answer to my question. I have written a custom plugin for wordpress which we will be using on our site. It was easier to make this a custom plugin rather than trying to use or hack existing ones.
As an example, let's say we are selling cars. My plugin lets us create a new car, upload a photo and write reviews about that car. This is all done through my plugin.
I now need to integrate that to the existing site using friendly urls.
I'd like domain.com/cars/ford-focus/2234 as the url. that would look like index.php?pagename=cars&model=matched[1]&otherid=matched[2]
also domain.com/category/hatchback would be index.php?pagename=category&cat=matched[1]
Both those urls would call a function and I will display the records on the page.
I am really struggling as to whether I create a page called "cars" and have a [shortcode] or do I handle everything in my plugin and rewrite urls. I have tried all sorts and its just not working. I don't know if I fully understand the way it works!?
Also - I have tried the route of using custom post types etc, but for our needs it's not right.
Thanks for any help!!

Is it possible to display and search data using orchard cms from an external datasource?

I'm just starting to play around with Orchard CMS. I like what I see so far, but I need to be able to create pages that display record details for data stored in another system. Does any one know if that is possible?
I have a SQL Server database that hold real estate property record information. This information gets displayed on the web. On that same website are informational content pages (FAQs, Contact Us, Home, etc...) What I would like to to is leverage the CMS portion of Orchard for the content pages. Then I would like to write a module using the Orchard that would get the real estate info, allow users to search parcels, and display detail pages for each parcel.
If you view the site http://www.sc-pa.com/search you can search by last name "smith" and select one record. That may help illustrate what I need Orchard to do.
Yes, that is possible, but your scenario is way too vague to get into any specifics. Can you elaborate on exactly what you are trying to do: what does the external data look like, where is it stored, how do you want to integrate it into Orchard, do you need any integration with content types and parts, or with search, etc.
One alternative is to expose ur data as web service or odata endpoint and then use jquery to do asynch call to get json data. Then ur home free.
Create a page and put the javascript in that or include a ref to js file.

Drupal: storing images and other module data

Suppose we have a module that displays tables of employees. Each employee has a photo. What is the best way to store this photos and display them?
I mean, is there some kind of content repository in drupal? I don't want to do this manually, maybe there is an API that can store images and then generate links to them and so on.
Thanks.
The Content Construction Kit(CCK) / Fields in core is what you want to explore.
Using CCK you can attach an image, a number field, a file, some text, a reference to content, etc to another piece of content.
In Drupal 7 you can add fields to any entity (Content, User...your custom one(Employee)), in Drupal 6 you might want to explore Content Profile
Further Reading:
http://drupal.org/node/717120
There is a kind of content repository in Drupal: both in the database and as storage (disk).
The API for that is documented in a special File upload section.
If you want inspiration, the core module called upload.module can serve as example. But be aware that Drupal core, for several reasons, is far from the best and cleanest examples to learn from.
What you are looking for is CCK module with file-field and image-field modules for handling the image upload action.
And for the display of those uploaded images you should use Image-cache

In a sitemap, is it advisable to include links to every page on the site, or only ones that need it?

I'm in the process of creating a sitemap for my website. I'm doing this because I have a large number of pages that can only be reached via a search form normally by users.
I've created an automated method for pulling the links out of the database and compiling them into a sitemap. However, for all the pages that are regularly accessible, and do not live in the database, I would have to manually go through and add these to the sitemap.
It strikes me that the regular pages are those that get found anyway by ordinary crawlers, so it seems like a hassle manually adding in those pages, and then making sure the sitemap keeps up to date on any changes to them.
Is it a bad to just leave those out, if they're already being indexed, and have my sitemap only contain my dynamic pages?
Google will crawl any URLs (as allowed by robots.txt) it discovers, even if they are not in the sitemap. So long as your static pages are all reachable from the other pages in your sitemap, it is fine to exclude them. However, there are other features of sitemap XML that may incentivize you to include static URLs in your sitemap (such as modification dates and priorities).
If you're willing to write a script to automatically generate a sitemap for database entries, then take it one step further and make your script also generate entries for static pages. This could be as simple as searching through the webroot and looking for *.html files. Or if you are using a framework, iterate over your framework's static routes.
Yes, I think it is not a good to leave them out. I think it would also be advisable to look for a way that your search pages can be found by a crawler without a sitemap. For example, you could add some kind of advanced search page where a user can select in a form the search term. Crawlers can also fill in those forms.

Resources