Hide CustomAction in SiteSettings page at subsite level - sharepoint

I have two features that add CustomAction to the SiteSettings page. One feature is at the Site level and the other is at Web level.
The CustomAction that is being added at the Site level is a link to the custom configuration page that manipulates Site level settings for my application. Therefore, I don't want the link displayed for the SiteSettings page of a subsite. I know there is a setting (RequireSiteAdministrator) that hides the page according to access level, but I would still like to have this page show up for Site owners at the top/root level site settings page and not in the sub site level setting page.
There is a RootWebOnly attribute for the CustomAction xml node which would solve my problem. The problem with this attribute is that it only available for SandBoxed solutions.
I know that this is possible, since I see the behavior for the Site collection administrators link in the Users and Permissions section of the Site Settings page. Please notice that if you go to the top/root level settings page, you will see this link. On the other hand, if you navigate to the Site Settings page of a subsite, the link is no longer there.
I have tried using HideCustomAction, but this hides the link on both pages.

After battling with this for two day, I had an ah moment that I thought I would share. This will allow you to place a custom action that will show only at the root web level.
Create 2 features. One at the site level (siteFeature) and one at the web level (webFeature).
Make the web feature hidden so that it can't be accessed (activate/deactivate) though manage features page.
Put the custom actions element xml in the web feature.
In the activation event receiver of the site feature, activate the web feature.

UnfortunlyUnfortunately this is not possible with custom actions and custom group.
All you can do is just to set up permissions on the link that will be shown only to SiteCollection Administrator
Example how it will be is "Site Collection Administation" group where links are hidden when you are not on the top site level and shown when you are.
Hope it helps,
Andrew

Related

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

How to add an application page to a site in SharePoint?

I am an experienced .NET Developer acting as interim SharePoint Developer, and am new to SharePoint. After determining that I need to go with an application page instead of a site page for a new project due to it's complexity and need of custom code behind. Before developing the entire solution, I wanted to tie up the loose ends of my understanding of application page deployments. I need to add this page as a URL on the left side of a Site Collection page (kind of like what happens when adding a subsite to a site page.) I have read about the modules, which seems extremely hacky to me. There must be a better way to develkop a custom page on top of SharePoint without the page being accessible to anyone on the entire site.
EDIT
The application I am wanting to develop on top of SharePoint exists purely for data entry and reporting purposes.
Have you considered using a Webpart?
With a visual webpart which is essencially a usercontrol wrapped in a webpart you can add as much complexity as you want and you also have code behind to hook to events etc.
The benefit of using a webpart is that you can then drop it on a page, and use all OOB sharepoint access controls.
You mention that you want to develop a data entry reporting app. So something you can do is to create a subsite. Look all access to modify pages except to owners. Create all your screens by adding pages to the subsite and dropping webparts on it with the logic you require for each screen.
Also make sure you deploy the werbparts via a web feature that only is activated in your subsite, this way the webparts are only available in that particular subsite.

Sharepoint page level security

Another SharePoint question from myself!
I've created a subsite and from within Sharepoint designer I've created a new aspx page, all nice and simple so far. I can't seem to find where I can change the security on this new page, only site admins can view the page and everyone else gets access denied.
It doesn't seem to inherit the permissions from the parent and I can't see where to change the security settings!
Please help, I'm sure it's something simple!
Thanks
Dan
You've placed your ASPX file in a 'bad' place. It doesn't sit where the normal security structures for SharePoint work so you won't be able to set its item level permissions (because it is not an 'item'). This is the danger of giving people SharePoint Designer ;)
Personally I think your page belongs in the _layouts folder somewhere since it seems to be an admin page. In there you could simply secure it by a call like:
SPUtility.EnsureSiteAdminAccess();
Either you can:
Put your page in a library so you can set item level permissions to it
Create a custom control that allows you to call the code above for any page
Move the page to _layouts
From SharePoint, you should be able to navigate to where you stored your new aspx page (probably in one of your Document Libraries). From that location you can either change the permission of the Document Library, or manage the permissions of an individual aspx page.
Please note that it is best practice to set permissions at the Site Collection level and allow everything under the Site Collection to inherit permissions.

Sharepoint features, custom aspx pages at various site levels

I've asked a similar sort of question here but what to be more specific.
I want to be able to deploy a solution and activate a feature that provisions various custom aspx pages to different site levels within my web site.
So my first custom aspx page would be at the root: http://example.org/custompage1.aspx
And then another custom aspx page would appear at a deeper level: http://example.org/subsite1/custompage2.aspx
I've got my solution scoped to the "web" level. If I activate the feature at the sub site level I can access the custom aspx page that should appear at this deeper level, but, I can also access the other page that should only appear at the root of the web site e.g. http://example.org/subsite1/custompage1.aspx
Which is wrong, wrong, wrong!
I tried to scope the feature to “site” but this only seemed to provision the root custom aspx page, not the page that should appear at the deeper level of the web site.
"Custom aspx" pages are known in SharePoint as "Application" pages, and they are deployed in the _layouts directory (usually C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS). All pages inside the Layouts directory are available from every site in the web application.
If you know in advance which page goes with which site then you could put code in each custom page that checks to see if it's being accessed from an "invalid" site, and if so, throw a custom 404 error (see here: Hidden Features of ASP.NET) or something similar.
Anything you do in the feature xml will only apply to the site on which the feature is activated. If you want to do something across multiple sites based on relative urls, you will need to set up a feature receiver and use custom code to deploy files/features to the other sites.
The easiest approach is probably to create a seperate web scoped feature within your solution and have the site scoped feature receiver activate it on subsites.
Clorphil nailed the answer. I would only add that you can use SPContext.Current.Web within your page to determine which web site you are in when called.

SharePoint 2007 Publishing site with deep menu structure

I am a beginner in SharePoint and I need to create publishing site that will have multilevel menu. Requirement is that levels will not be fixed and that client should be able to add pages and customize menu.
If I am not mistaken pages can be created only in the first level under the site. I don't see something like folders concept. For the navigation purposes I can add heading and it will be shown as another level. If I need more levels I need to create sub sites.
Site
Page1
Page2
Heading
Page3
Is this correct?
Site
Page1
Page2
Sublevel_1
Page1_1
Sublevel_2
Page2_1
Sublevel_3
Page3_1
...
Can I do something like this without creating SharePoint sub sites ?
If I don't need I will skip writing some custom menu control or write custom SiteMapProvider. I will than need to write UI for managing navigation also.
EDIT:
I have managed to create Folder in Pages list and create (actually move) pages to that folder and even create sub folder but they are not showing on the menu not even in the navigation settings page. I can't approve folder, it is in pending status what ever I try.
I looks like this is not possible by the Andrew Connell: Subfolders are not Supported in the Pages Library in MOSS Publishing Sites
Out of the box, you can modify the navigation for a Publishing site manually.
I assume that you are after a more automated way to do this. Unfortunately, the way to modify the navigation for a PublishingWeb is through the object model and the PublishingWeb.CurrentNavigationNodes object, which would require a timer job or some other method to update as pages are edited/added/deleted.
This is non-trivial and you will still need to create a solution/feature package.
The other way is to create a custom navigation provider.
The issue with both of these options (aside from the actual coding and release) is caching the navigation structure. We have used the standard web cache for the object holding the navigation structure, but using the standard user browsing (i.e. the menu code itself) to kick of a refresh of the navigation is fraught with threading issues.
You can create multiple document libraries in a site and then put the pages in the various libraries. That way you wouldn't need to create sub-sites

Resources