How to use Relative URL for HTML links in Site Template for a Hero WebPart - sharepoint

I'm using Office365 for my company's Intanet Portal.
We have customized a SP Site and added a Hero WebPart on Modern Home Page, Edited the Links in that Webpart which points to some List and Lib URL in the same site.
List and Lib URL Links:
/sites/test/DocLib1
/sites/test/DocLib2
Then we saved the Site as a template and created new Project Sites based on the template.
Everything works fine, but the Links in Hero web-part is pointing to the Site Template Libraries URL and not the newly created Site Library URL.
I need to make this work, I can apply custom code also using JS or any other way.
Please help
We are using Modern Site Pages.
Thanks in Advance.

You could use properties from SharePoint JavaScript object _spPageContextInfo:
_spPageContextInfo.webAbsoluteUrl
_spPageContextInfo.webServerRelativeUrl

Related

Changes to page template is not updated to old pages created from template

I have created page template in site pages library of SharePoint online and created some pages from it but when I change the template layout changes are not reflected in the old pages which are created from it. Please let me know if there is any way to resolve this issue.
I'm trying implement the functionality similar to page layouts in classic SharePoint sites. If there is no way to resolve this issue using page templates will it be a good idea to enable publishing features in modern SharePoint site and create page layouts in it.

How to edit a page in the SharePoint?

I have some custom codes in form of HTML which I wanted to add to the SharePoint. I find out there are two ways to do it, one is using the SharePoint Designer and the other one is uploading the page. However, this is local SharePoint in my Windows Server and I want to modify the page locally because I have limitation when using the Designer and Upload page. I also don't want to add a new page and I would like to modify the current page using my own code.
Are you able to help me out?
Edit the page> insert the Embed Code web part to add custom HTML codes:
More information for your reference:
https://www.c-sharpcorner.com/blogs/how-to-add-html-page-to-sharepoint-site

SharePoint 2013, change welcome page layout when a sub site is created

we have a custom page layout, and we want this:
When a new sub site is created by users, we want the default.aspx, AKA welcome page to be based on our custom page layout.
How can we do this?
Two options:
1) Create a custom web template and define a module for the welcome page. This obviously only works for that custom web template, but does not require code.
2) Create a web event receiver (e.g. WebProvisioned), apply it to site collection. In the code behind set the page layout of the welcome page to your custom page layout. This works for any template, but requires custom code.
Option 1 only works in a farm solution, option 2 should also work in a sandboxed solution I guess.
I believe you want this OOTB (Codeless).
Go to page (you want to make home page) set the layout. (you custom
layout).
Set this page as a home page.
Remove all data (lists, libraries, pages). except this page.
Save the site as site template(_layouts/savetmpl.aspx). If you are not finding the save as template option. Write the url.
After saving the template, you can
use the same template for all your sites. For creating subsites,
this should be add in list site template in settings. Let me know, I
can explain you more.
Thanks

Setting up default web parts on a Wiki Page from a Web Template in SharePoint 2010?

My team is trying to build out a Web Template which includes an instantiated Wiki Page with some default Web Parts added to it; but we're unable to get this behavior to happen.
In brief, we're looking to add some default.aspx (or Home.aspx, the name is unimportant, just the functionality) to the SitePages directory, GhostableInLibrary; so it's visible to all SiteCollections made from this Web Template.
It is of note that we're basing our Web Collection off the Team Site, and that the Wiki will be the default Home Page for the new site.
Site templates can be used to customize newly created sites except for the top site of a site collection. Since site templates are all managed in site collection's Solution gallary, so a site template CAN'T be used to define its own container.
You need a Site Definition to customize the first site of your site collection.
For how to use site template, you can goto, http://weblogs.asp.net/soever/archive/2009/10/19/sharepoint-2010-site-exporting-as-wsp-solution-part-1.aspx
For how to create a site definition, you can goto, http://msdn.microsoft.com/en-us/library/gg276356.aspx
If you want to strap onto an existing template without creating a new copy, or you don't have the original site template to access. You use a process called feature stapling.
When you create a sharepoint solution it would contain two features, one for your actual functionality and one that simple staples it to an existing template.
Here is an article discussing it some more. http://mssharepointtips.com/tip.asp?id=1065

How to provision a custom page without using the _layouts directory?

I need to provision a custom aspx page which does some work and then redirects to another page. Using a _layouts page, AKA an application page won't work since I only want this page accessible to one site collection.
I looked at using pattern #4 from blog post Application Development on MOSS 2007 and WSS V3. It feels pretty hacky, and it asks you to drop the DLL. Drop it into the bin of the site collection, and upload the file through SP Designer.
I'd rather have this page be a feature that gets included in my site definition or stapled to an existing site definition. I imagine I could use a feature receiver to deploy the files to the pages SP list. One of the comments on the blog post says as much:
Pardon my ignorance on this maybe I am
missing the point completely but
wouldnt it be easier to deploy your
custom pages by programmatically
adding them to the pages splist?
I basically, had a simple .aspx page
with a user control. I deployed it via
this method.
How can a custom page be provisioned without using a _layouts page?
I guess another option is to keep using a _layouts page, but make sure the referrer is correct.
Besides application pages, you also have the possibility to create site pages.
Site pages are in nature related to application pages, but they reside in a site not in _LAYOUTS.
The welcome page (default.aspx) is an example of such a page.
In the same way as with application pages, it is possible to do codebehind in these pages (check out AC's article on this subject, Using ASP.NET 2.0 Code Behind Files in SharePoint v3 Sites)
You can read this article regarding the subtle differences between application pages and site pages: SharePoint Application and Site Pages - Part 1 of 2
You deploy this custom page using a feature, where you specify the file as ghostable (look at the example in ACs article).

Resources