Plugins for users to use on websites-PHP - php

I am using CodeIgniter to make a website.
I want to provide users with Plugin/Iframe/banner etc so that they can use it simply by copy pasting code.
I dont want to make image banners because of limitations and dynamic data.
Like the facebook one below .
It is clickable with different links unlike Image banners.
The data in the Box will change every time page is refreshed(almost realtime).
the box should be dynamic i.e different for user with ID1 ,ID2.
Using iframe is an option with something like example.php?banner=ID1
But i dont want user to edit links /text in that.
How should i proceed ?

It's simple.
[ 1 ] Start building your dynamic application. You can provide unique URL to each user based on USERID or USERNAME like
http://www.stackovrflow.com/users/content/{user_id} OR {username}
[ 2 ] Create JavaScript API / Restful API. When Visitor clicks on the link control the click with JS. I mean open new window like Facebook or redirect to your website. The page load above dynamic URL. See the details about New Window.
How can I open a link in a new window?
[ 3 ] This is quite possible using IFrame also providing few lines of code. But it is not preferred. Using / Providing API is always best.

Related

How should I build a website for someone else who wants to embed their own Youtube links?

first post here.
I am making a site for someone who wants to embed their own youtube links. I am relatively new to web development and this is my first commission so I was wondering how I could hand over the site to the client and allow them to upload their links without me having to edit the mark up for him.
I understand how to use an '<iframe' youtube link in HTML to embed videos and am considering creating a database using PHPmyadmin that uses a form that the client can fill in with the iframe link whenever he needs to embed a new video.
I understand if that sounds like a convoluted way of doing this but if anyone knows a more intuitive way to solve this issue please let me know :)
I think it can be done using a database, may be MySQL, to keep it simple and a simple backend programming language, PHP would do.
You create an admin page just to collect the URLs from the admin. A nice little login page which stores admin username and password in a table. And you can use this module to assign roles to admin, add an admin or delete one.
Inside the module created above, create a page with a form to fetch and store URLs in the database. If you are going to categorize the videos, use suitable columns. Say you are going to categorize based on the genre and length, the table in your database should contain genre and length so that you can use them as filters later on.
Use cookies to create session for the admin. This is to avoid redirecting him to the login page after every single reload.
For all other user who is not admin, do not redirect to the admin page. Redirect them to a common page where they can search and enjoy the videos that the admin has added.
Again, like mentioned in many comments above, wordpress does it all. You have an option to use it too, it's free.

Ajax load contents and append related urls

I am trying to use Ajax in a Project.
The Idea is when i click a Tab,
The Relevant Data should load according to that Tab.
But it also should append the Url on address bar of current form that i am in.
Let Suppose i clicked the ERP Tab, so then ERP Divs should load inside the page but also the relative url should also show
e-g
www.mydomain.com\erp
i know about .load function, but with it it dont update the url on address bar.
plus data will be coming from different files.
Also Left Side Menus will be coming from Database on Role Base.
i am using codeigniter in this project
i want to have Url functionality as it will be easy for user to access that page directly with the complete url plus it also gives bookmark advantage too..
Here is the screenshot for more convenience.
AFAIK you can't change the actual URL without a page reload.
You'll have to use 'jquery-address' library. Check out https://github.com/asual/jquery-address
I would do two different things here:
To change the URL dynamically without page load, use the new history.pushState() method. If you are supporting older browsers, history.js is essentially the same API that falls back to a hashtag method. Note that these URLs are not accessible from the outside. Thus:
When a user travels to one of those URLs, default the open tab to whichever one you are trying to. You will have to capture the intended route and work some javascript magic on it.

How to use same database for a html based fanpage and php based site?

I tend to place a sign up form on facebook like on the website that is being developed for it. The site is developed by using php and Joomla. The fanpage is created using HTML and CSS. The site has a sign up area. I tend to put a similar (best if it is same) sign up area on facebook fanpage. Is there anyway that I can use the same data base to store both of them?
Thanks.
This is easily acheived using an iframe tab on your Facebook page, because it's inside the iframe the page you're referencing can refresh without refreshing the parent meaning you can post form data easily, remove to use target="_self" to make sure that this works as expected. Here is more information about it:
http://developers.facebook.com/blog/post/462/
Additionally due to width restrictions you may want to utilise ?tmpl=component on your Joomla website for ease.
Here are some loose instructions, I would give you a link to a podcast but Facebook application manager has just been completely overhauled so none of the tutorials I found are relevant, here goes:
1) Goto http://www.facebook.com/developers - It will ask for permissions press "accept"
2) then goto http://developers.facebook.com/apps
3) Click "create new app" in the top RH corner
4) Enter a name for your app in the popup, and agree to the terms (you may be asked to fill in a captcha afterwards).
5) Scroll to the bottom of the new page, and click on "Page tab"
6) Fill in the 4 fields, edit URL isn't necessary it can just point at your main url. https is a good to have as a lot of people use Facebook through https.
7) Press "save changes"
8) In the left hand column click on "view app profile page"
9) Then on the new page in the left hand column click on "add to my page"
10) Pick your page from the popup that appears.
11) goto your existing page, click on edit page and you will see the option to create a new tab using your iframe application.
Let me know if you need more details but these simple instructions should get you most of the way accompanied with the Facebook doc I posted above.

Share multiple items on facebook

I need to build a page with 2 different facebook share instances.
- there is a video i want the end-user to be able to share on his/her profile.
- and then, there is the page itself, which i'd like the user to share.
how to build a page that can let users share 2 different items on a single page?
You just need two separate Facebook Like Boxes or Buttons (note that Like Boxes can only reference Facebook Pages), each configured to the relevant URL (either the video or the page). You'll only need the script and fb-root tab once on the page.
Like Button documentation
Like Box documentation

Bookmarking Ajax pages

Let's say I have a URL: http://example.com/person/list
This website will display a list of people. The list of people get very long, so eventually I build in pagination. Let's say 10 people per page. The URL looks something like this:
http://example.com/person/list?page=2
If I click the next page link, I will be taken to page 3:
http://example.com/person/list?page=3
This is good because if I copy and paste the URL to a friend, she will be directed to page 3 immediately.
Let's say that I now incorporate AJAX, and the page requests are ajax calls using jQuery. The original URL is http://example.com/person/list and when a user clicks on the next page link, the URL in the address bar doesn't change.
This is bad because if I'm on page 3, the URL in the address bar doesn't reflect this anymore.
There are multiple jQuery history plugins which will change the URL, however, these will ONLY change the portion of the URL which is after the hash mark #. Information after the hash mark is not sent to the server.
If I'm using a history plugin, the URL can be changed to http://example.com/person/list#page=2
My problem with this approach is: If someone copies and pastes this URL to a friend, when the friend requests this URL, I have no idea which page the user is intending to look at. Therefore, my best approach is to load all of the people entries onto the page, and have javascript select which page to display based on the information after the hash mark. This is a problem because I started to paginate the pages to reduce the amount of information being pulled back from the server in the first place!
What options do I have, such that I can have the back button be usable with Ajax, but also have bookmarkable links which do not require me to get all info from the server.
As I recently learned from my question you have to check the hash-part of the url after the 'friend' opened the link and fetch the content using ajax.
Or you can rewrite it on the server-side to http://example.com/person/list?page=2
You could not list anything until the page loads and then have ajax load the appropriate page.
Another option would be to load the first page as normal and then have javascript check the page hash to load the appropriate page.
For very small loads (and I assume loading 10 people is 'fast'), the second option is probably the best as it shouldn't cause too much disruption of the UI.
Option one has a downside as far as SEO goes, as search engines won't index the content if it's not loaded.

Categories