Adding HTML from an internal file to a Web Part on SharePoint - sharepoint

I have developed a SharePoint Web Part where I have an iframe that I need to load with several pages depend on different values.
For instance, I have this files
file1.html
file2.html
file3.html
And I need to pass the path of one of this elements to an iframe
Where can I put this files and How can I retrieve the right path of this pages?
Regards

Try to save the html files in a library and set the iframe url dynamically.
$('#iframeId').attr('src', url)

Related

How to prevent website being grabbed by IDM( or anyother webstie grabber)?Is there any way to prevent it?

Using website grabbers whole website with folder structure can be downloaded.
Is there any way to prevent this?
If so,how?
The only way to protect a websites markup is not to publish it. If you want your users to see something they need to get the HTML markup and the images, that should be displayed. And therefore the files need to be accessible. And if your files are accessible every user/bot/crawler/grabber can save these files.
The best way is to put a few files like the index page in the main directory and call the other sub pages in it. If using php then you may do the following.
Say keep the index.php in the main folder and keep the homepage.php in a directory called includes and use the homepage in the index.php via include function in php.
Now add a .htaccess file to the includes folder which must contain
"deny from all"
This way users can use the page but will not have direct access to the files. So will be for the grabber.

How to load a PDF from outside the project folder using p:media tag

<p:media value="C:/Users/xyz/Desktop/sample.pdf" width="100%" height="600px">
</p:media>
I'm using this code to load the PDF placed on my desktop but it is not loading the PDF from that place.I searched a lot but unable to find the reason.So from JSF experts I want to know that is it possible to load a file/pdf/image (any resource) from outside the project's folder using primefaces media tag? If yes then How?Note: I am able to load this pdf if i placed it in my project's folder.but I want to load it from outside.Thanks
The value must point to a valid URL, not to a local disk file system path. It's the webbrowser who has got to download the PDF from that URL. It's not the webserver who has got to auto-include the PDF in the HTML output somehow as you seemed to expect.
You can't expect from every webpage visitor that they have exactly that PDF file in exactly that location on their own local disk file system. Let alone that they also run Windows.
Easist way would be to move that PDF into the public web content folder (there where you also put your JSF pages in) and reference it as follows instead
<p:media value="/sample.pdf" width="100%" height="600px" />
Assuming that the JSF page in question is served through http://example.com/context/page.xhtml, then the webbrowser will download the PDF by http://example.com/context/sample.pdf (and you need to make sure that it's also individually available by exactly that URL).
A different alternative, if you don't want to put PDF files in your webapp, but elsewhere, is to add exactly that disk file system location as "virtual host" to the server configuration so that it's available by an URL. You can find some hints here: How to show the server path image to PrimeFaces p:graphicImage?

Links on SharePoint 2010 Master Page not changed based on Alternate Access Mappings

We are creating a custom branded Master Page in SharePoint 2010. To make the page similar to a legacy page we have implemented an html based custom dropdown navigation menu we had in place directly on the Master Page (consisted of basic HTML elements ULs and LIs with A tags styled with a CSS class).
I assumed the links from the basic HTML on the page would be subject to Alternate Access Mappings currently in place, but it seems to not be the case. On a test page opened in 3 different URLs (http://sharepoint2010, http://sharepoint2010.mydomain.com, https://sharepoint2010.mydomain.com) the links from a WIKI page are modified as I expected, but the links from the Custom Navigation Menu (plain HTML on the Master Page) are not modified.
I can see where that would be useful... But is there a way that I can add links on the MasterPage in a way that SharePoint parses them first, making them subject to Alternate Access Mapping translation? I tried placing a link inside a SPLinkButton control, but it didn't achieve the desired behavior.
e.g.
<ul id="navmenu">
<li><SharePoint:SPLinkButton runat="server" NavigateUrl="http://sharepoint2010">sharepoint link</SharePoint:SPLinkButton></li>
<li>sharepoint2010</li>
<li>test</li>
</ul>
When I access the page via https://sharepoint2010.mydomain.com the links above are still http://sharepoint2010 rather than https://sharepoint2010.mydomain.com
Any thoughts?
Thanks,
Victor
EDIT (clarify):
I was planning on using relative links as a fallback. But for the purpose of what we are doing it would be more maintainable if we could keep the full links and use AAM.
I'm aware that standard relative links are a possibility. I was hoping to identify if there is a way to use AAM on Master Page content (or even on Content Retrieved from External Services down the road) by providing a specific link syntax, or control framework.
There is no need to re-insert the host name if your links are on the same domain and you're not using managed paths. Keeping your links relative will ensure that any bindings in IIS and AAM setup in SharePoint will work without any additional work.
Otherwise, I would heavily suggest to use the available ~sitecollection and ~site SPUrl token to retrieve the current site collection url or current web url. You need to wrap it in anything running server side as the expression will be handled ... server side.
eg:
<asp:Literal runat="server" Text="<% $SPUrl:~site/press-releases/ %>"/>
Hope it helped
When you use the NavigateUrl= attribute of the SPLinkButton, SharePoint renders a simple anchor with href= instead of regular PostBack JavaScript code. Alternate access mapping do not play a role here.
If its simply relative links you want, then leave out the dns entry altogether (ie the bit of the url you are switching with your AAM) and begin the url with a forward slash to make it relative. If this doesn't meet your needs, the way Sharepoint does it is with a relative url token. Have a look in v4.master for the tilda character followed by 'site' or 'sitecollection' which refers to the current web and site collection respectively. Copy this method. For more details, look at this link: http://msdn.microsoft.com/en-us/library/ms473643.aspx

is it possible to redirect a link to a pdf file

is it possible to redirect a link to a pdf file?
This is my site: www.mysite.com
And I createad a redirect link that if I open www.mysite.com/documentation - an index.html file will open but for now this index.html file says it's under construction.
Can I redirect the link to a pdf file?
I uploaded the pdf file into the server. So that if I open www.mysite.com/documentation, my pdf named as thedocument.pdf will open.
Is it possible?
If your web hosting provider won't allow you alter the default extensions (i.e. to add pdf) then you could create a HTML page to act as the landing page and then redirect to the PDF.
Details here: http://www.web-source.net/html_redirect.htm
Yes, this is possible. Check your web server configuration that currently points /documentation to index.html, and change it to point to thedocument.pdf.
Be aware that the PDF may or may not load in the user's browser. Some configurations will prompt the user to download the file.
You can achieve this with a modX Weblink.
Upload your pdf to a place from where it is publicly downloadable. For this example I will upload it to modx/assets/content/test.pdf. You should now be able to download your file from http://yourdomain.tld/assets/content/test.pdf.
Create a new weblink resource in modX (Site -> New Weblink) on the base level of your resource-tree. Make it a container and type in 'documentation' as the alias of your resource. You should also make sure, that you already use friendly urls, but your question sounds like you're already doing this.
A weblink has a field to enter the 'weblink' instead of the ressource content. Just use the URL from which you are already able to download your pdf-file. In this example, this would be http://yourdomain.tld/assets/content/test.pdf.
If you now view the newly created weblink resource under http://yourdomain.tld/documentation, you should instantly download a copy of your file test.pdf.

What is the URL to the Sharepoint mapped images folder

How can I, using the Sharepoint object model, get the URL to an image placed in the mapped images folder?
(added) I am deploying the image as part of a Visual Web Part (named ProgressWebPart for my site).
You should use the server relative url for static images:
/_layouts/images/ProgressWebPart/myImage.png
While the site relative url (no leading slash) will work, consider what happens when your web part is used in two separate sites. A user visiting these two sites would request the following images:
http://server/site1/_layouts/images/ProgressWebPart/myImage.png
http://server/site2/_layouts/images/ProgressWebPart/myImage.png
Even though both requests return the exact same file, the browser considers them distinct because they have different urls. By using the server relative url, you ensure that the user only downloads the static file once. If they visit other sites which use your web part then the browser will use the copy inside it's cache saving both time and bandwidth.
You don't need to use the OM to get this - its static and determined how your solution is packaged.
For an example - the default site logo for SharePoint 2010 will be here
_layouts/images/siteIcon.png
So http://yoursite/_layouts/images/siteIcon.png
and htp://yoursite/yoursite/yoursubsite/_layouts/images/siteIcon.png
It turns out to be (for my 'ProgressWebPart'): "_layouts/images/ProgressWebPart/"
As such, loading a PNG file into an Image control can be done in C# with:
Image image = new Image();
image.ImageUrl = "_layouts/images/ProgressWebPart/myImage.png";

Resources