Insert HTML/php file into SharePoint 2010 master page - php

I've been searching high and low for an answer to this. Hopefully I'm missing something obvious.
In a SharePoint 2010 master page, how can I call to a centralized file to load code into the master page? My problem -- I've been tasked with creating a way of having navigation load from one central file to be loaded on several different site collections's master pages. This needs to be html, and not the typical SP navigation, as I'm using a jquery megamenu solution.
I got this to successfully load with javascript but maybe because I'm using a megamenu with jquery dropdown, it slowed the page load to a complete crawl. I considered a CEWP but don't think i'll be able to strip out all the CSS to make it load seamlessly - although this might be the way I have to go.
I'm hoping for a workaround with the php include command. Thanks in advance for any help!

You can't run PHP on a SharePoint site. You can however, create a web part or other C# code to include on your master page to render your menu. A jQuery solution should work as well. If it's slowing your page load down, maybe you should create your menu after the document is ready.

Related

Should I add home page HTML in wp classic editor or front-page.php for speed?

The title basically says it. I currently have my home page with the HTML sitting in the classic editor box. Should I move that to front-page.php? I know that it doesn't REALLY matter, and it won't have a huge impact, but I am being meticulous about creating a speedy website. So which is faster?
Also, I am currently using 2 separate PHP files for headers. One on the home page, and one for the rest. Should I just hard code the header for the home page into the same place as the home page HTML since it's the only page that uses it?
I'm pretty new to PHP, but I've searched Google extensively and can't seem to find my answer. Using WordPress. Really appreciate your help!
For speeding up the website, no need to change the home page or the header file. please do the following things for speeding up the website
Optimise your images
Enable caching
Enable GZIP compression
Minify CSS, HTML & JS files
Update plugins
Clean-up your database
Moving the html code to a template file will improve the site speed because WordPress will not have to retrieve those html tags from the database. And it is conventional and actually a good practice to place all rendering code (html, css, js) to the template or theme files where they should be, instead of directly adding them in the backend or instead of including them directly in the post editor.

PHP Widget layout grid

I'm building a webapp which main purpose is displaying widgets on a display. These widgets have an variable size, so not every widget is even high or wide (But they are using standards like for example a grid system). Now I'm looking for the best way to save which widgets are used, and where they are placed. For example by using something like Gridstack the user can drag and place the widgets in an admin panel, but how should I save this? And how can I recall this and put in a empty Bootstrap page for example. Working with the Bootstrap Grid system would be great aswell.
I did some research on Google and here but didn't find any plugins or ways to do this.
I'm using 'Gridster' at the moment which this Gridstack is built off of/inspired by, so it probably won't be able to save for you.
You'll need to do that, either by sending it back via AJAX or storing in local storage. As it looks similar, you should be able to find a 'serialization' function which should wrap it up ready for you to send to your PHP via AJAX.
You may need to scan through the widgets and wrap them up in your own JSON string, such as the row/column/sizex/sizey which is all the grid system really needs to "add" a widget when its first loaded up, so as long as you can feed that back in you should be good to go.

How to create unchangeable part of html even though the browser's current urls changed?

I have searched about that for very long time. But I havn't known how it works and how to create it. I am so serious to get it. I am a beginner of Ajax and JQuery. I wish to create a fixed mp3 music player in my web. Although I have some code and know how to do mp3 player for html5, but I have not knew how to do fixed mp3 player which won't change playing when another pages load. Could you help me, please. Example: it is like of www.revernation.com and facebook's chat popup box, still active without refreshing another pages.
You can't keep an mp3 player running when the user navigates to a completely different site in the same browser window.
You can however keep the current page open and fake navigation to other subpages of your own site with History API + AJAX and DOM manipulation. The trick is sometimes called pjax.
An example implementation: https://github.com/defunkt/jquery-pjax
Angular.js does what is described in the previous answer.
What you need to do is convert your app into an SPA.
Single-Page Applications (SPAs) are Web apps that load a single HTML
page and dynamically update that page as the user interacts with the
app. SPAs use AJAX and HTML5 to create fluid and responsive Web apps,
without constant page reloads. However, this means much of the work
happens on the client side, in JavaScript.
Best for SPA
i suggest you to go with AngularJS.
You can still do it with JQuery with Ajax calls if you don't want to use other front-end frameworks

What is the best way to develop dynamic jQuery Mobile mobile app?

I need to develop mobile app with jQuery Mobile which will be packed with PhoneGap Build and distributed on Google Play. I need to have dynamic listviews which depending on which item is clicked will open new dynamically generated page which got information from MySql database.
Current setup is I generate listview with urls with different variables attached (category.html?cat=1, category.html?cat=2, ...) when I click on item the pageinit event is triggered for category.html and I parse (with JS) the url variable (cat=2) and I send query to my PHP page (which in turn query MySql) through $.get method and I insert the returned value (which is listview echoed back by PHP page) with $('div.ui-content').append(data).trigger('create'). This way sometimes works, sometimes doesn't(the page stays blank) or you must refresh the whole page etc. ...
Is it better to generate whole html for page in PHP and dynamically transition to new page with changePage() method? Or is any other method better?
Thanks :)
best way is to use 3 components,
server side framework: Slim is the easiest for this, nice simple routing, easy to implement, you can also do symphony, rails, etc
middleman: handlebars is great for inserting incoming data into html, try it for sure. angular is good as well, more complicated though. also with handlebars, you can have a different template file for every different page, very easy to maintain.
front end: jquery mobile is the most compprehensive i believe, ajax requests are piece of cake, and in the requests you can call your handlebars templates and insert stuff on the fly.
PS: you are still doing all this with "one" html page, but handlebars is helping you insert sub pages on the fly, jquery mobile helps you change the pages

Web app integrated in a CMS

I want to build a site that allows user to get filtered subsets of some information I have stored on a database. The information will change frequently and I will want to create a post every now and again to say when new information or features become available, so the site has CMS aspects and web app aspects.
Coming from a desktop programming environment, I have to admit I'm not entirely certain how far a CMS like Drupal or WordPress can take me. The web app would basically be a form with several interdependent options and a Submit button. When the Submit button is clicked, I would want to call a web service that returns the information in one of a variety of formats.
So will I need to install my CMS and have an iframe or just a link to the web app which is developed completely outside of it, or can I build my web app's front end directly in the CMS (and hopefully achieve a nice, integrated look) and just have it call the service behind a button?
I half-expect that this web app would become a WordPress/Drupal plugin, or am I barking up the wrong tree?
Yes you can do this. Try out jquery, I think is already included (at leas in wordpress). "Break into" the layot part add js file of your own that makes an AJAX call to a url and returns some HTML from there and puts that content into a certain HTML component (a div that you also add there by your self with a certain id).
User clicks a button, triggers the ajax call and voila.
There are also complicated ways like developing your own plugin that makes SOAPCalls and integrated with the wordpress/drupal etc. But as you say that you are a desktop developer this is the closest aproach to you knwoledge and perspective.
AJAX LOAD WITH JQUERY

Categories