How to get website URL in a SharePoint custom masterpage? - html

I'm making a custom masterpage and on the navigation bar, I would like to have a button which goes back to the current site main page. This masterpage will be use for other subsites as well. Is there a way for me to get the current site URL within the index file?

You can use URL Tokens to get your site URL.
<SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" id="homelink">
</SharePoint:SPLinkButton>
Notice the URL token of ~site used in attribute NavigateUrl="~site/". You may have to use the $SPUrl command also.
<%$SPUrl:~site/myPage.aspx%>
You can also refer to this discussion for more usage examples.
NOTE: I haven't tried the above examples, but these should be sufficient to provide you a path to your answer.

Related

Embed Form from Planning Center to Wix

We are trying to embed a form from Planning Center People to our Wix website. The code given is not compatible with Wix and we keep getting a "parsing error unexpected token" message.
Here are the instructions from the PCP website:
Step 1: Include the ChurchCenterModal script tag on your webpage in the of your document:
Step 2: Add a link to your website (the location, name, and style is up to you):
" data-open-in-church-center-modal="true">Fill out our form!
Alternatively, if your website's content management system doesn't allow you to control the html of the link, you can also use a parameter in the URL itself:
?open-in-church-center-modal=true">Fill out our form!
Bob:
I think you need to do two things on your Wix site.
You need to add the code that is required in the header section of your page
Step 1: Include the ChurchCenterModal script tag on your webpage in
the of your document:
You do this in your site dashboard->settings->tracking tools and analytics page. Just cut and paste the code in a head section after click Add Tool.
You need to use the alternate link method for getting the form
Alternatively, if your website's content management system doesn't
allow you to control the html of the link, you can also use a
parameter in the URL itself:
Give
online
To use this you should add a button on your page and create an onClick handler that calls wix-fetch. Using the URL only not the rest of the HTML.
Should look something like this:
export function button1_click(event) {
//Add your code for this event here:
fetch("https://<your subdomain>.churchcenter.com/giving?open-in-
church-center-modal=true");
}
Hope that helps.
Steve

URL in HTML and URL for desired link are not the same

I am working with mining some links from a Chinese academic article database.
It appears that when I refresh the page to an article I'm looking at, or simply copy and paste a url, the url redirects to the database's home page rather than the article.
For example, the following link goes to my search results:
http://search.cnki.net/search.aspx?q=%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD
The first article's individual url is:
http://www.cnki.net/kcms/detail/detail.aspx?dbcode=CJFQ&dbName=CJFQ2016&FileName=KJDB201615009&v=&uid=
However, if you try to directly click on the article link or refresh the article page, it redirects to the database home page. Why is this happening? Is there any way to get a "stable" url to these articles?
One detail that may matter, although I'm not sure, is that the url in the HTML code to the individual articles is also different.
<a href="http://epub.cnki.net/grid2008/brief/detailj.aspx?filename=KJDB201615009&dbname=CJFDLAST2016" target="_blank">
It's not really up to you.
The website you are referring checks if the link you are opening is a direct link or was opened from another page on the same website.
This is probably to prevent embedding links of this website in other websites.
In short, it does not allow direct links to its articles.
You can see it by examining the header returned from the request.
Instead of 200 OK you get 302.
Which tells the browser to redirect to another location.
You can try and fool the website by adding a "Referer" header to your request.
If you look at the header
that works you'll see that there is one.
I did not try but I'm pretty sure it will work.

HTML remove url variables, NO PHP or JS solution

My site uses both PHP and the JS AJAX so I'm fairly familiar with them both, and I don't want a solution that includes them. I have this page structure where all my users stay on just one landing php page, which then fetches the right content depending on the URL's p variable.
http://www.example.com/?p=about
http://www.example.com/?p=aMap-anothermap-evenAnothermap-lastelyTheFile
This page structure works great for me except that I don't know the right way to make a link that just removes the whole ?p=home. Because I want my home/start page to be variable free. I want it to be
http://www.example.com/
rather than
http://www.example.com/?p=home
Now I could just make the link
http://www.example.com/?
And then just remove the ? with the JS pushState(), but that would look pretty silly and would only work for JS users.
Let's say i would want to the do the above example with just the ? then I could create a link like this.
Link
<script src="SomeCoolPushStateScript"></script>
And I know from experience that this doesn't even work:
Link
So here comes the question: How do I remove the ?variable=something part of an URL when using an HTML href?
The path ./ should do the trick.
Link
If you want to preserve the main script name, like index.php, you will have to include that name.
Link
Alternately, you could dynamically generate domain-relative or absolute URL's with PHP.
You don't need to use querystrings.
Link
would go to example.com's root.
I don't recommend using "./". This would do what you want if the user is on a page that is in the root directory of your website (e.g. http://www.example.com/page.html). However, this would not work if they were on a page in a subdirectory. E.g. if the user's on http://www.example.com/hello/page.html, it would just link to http://www.example.com/hello/.
Using "/" makes sure the user goes to the root of your website.

Parsing relative links on a html page

I'm trying to parse a page to find all valid urls, but here is a problem. There are 3 types of links on a page: url (_http://site.com/dir/page.html), absolute uri (/dir/page.html) and relative uri (dir/page.html without starting slash). Probably i'm wrong about terminology, i'm not an html coder. But that's not the case in any way.
I need to find and collect all urls (i.e. _http://site.com/dir/subdir/page.html and so on). And here is the problem. If there is a page _http://site.com/dir/page.html with a link like link it's supposed to bring us to _http://site.com/dir/subdir/page.html. But if there is <base href="/"> in the head section of a page, same link leads to _http://site.com/subdir/page.html i.e. different from _http://site.com/dir/subdir/page.html.
The question is if there can be anything else in html code on a page that can influence target url.
Thanks in advance.
In HTML as such there is nothing else beside the href base You mentioned
What could become tricky and should be considered is that there might be linkage on page made by script execution, so things like window.location.href = something. This would be easy if the links are clearly stated, but they might be also computed by the script and then You could miss the link or mis-read it by using simple parsing.
Your problem is actually how url linking in html works, please read: http://www.webdevelopersnotes.com/design/relative_and_absolute_urls.php3 . So say you're in /admin/ and you need /admin/login.aspx . My relative URL is login.aspx, while my absolute is /admin/login.aspx make sense?
So basically what I'm saying is consider which directory your link is being served out of. That will determine the type and content of the url link to use.
Other than that, as stated already, jscript and server side code can also do linking.

setting html parameter option dropdown value via url

I would like to set the default of a drop-down menu of a webpage by passing the default value in the url.
Id like to put a link on a another webpage to this site where the: "I would like my contribution to go to:" option is set to Pakistan: moonsoon floods e.g. by doing something like:
http://donate.ifrc.org/?desc=Pakistan: monsoon floods
but this doesnt seem to work. Any ideas i want to put up this link to get as many people to donate as possible. Thanks.
~f
Unless the site you are linking to has specifically included code on their pages to support it, you are not going to be able to control how their site performs by changing the URL.
If you were trying to do this on your own site, you could easily do it by referencing the querystring parameters in whatever server-side language you built the site with, or on the client-side via Javascript. But in either case, the site itself controls how it responds to a URL, not the other way around.