Sharepoint 2010 - how do I add a page using code - sharepoint-2010

How do I add a new page on sharepoint using code?
I am coding site using SPservices, javascript and jquery
I pull the link from a List and use this variable to call the web page.
however if the page does not exist -- I will get page can not be displayed screen when I click on the on click event
is it possible to do the following?
1, check if the page exists
2, if page does not exist create a blank page
any help would be very grate full as I have searched online for days on end to find a solution

You can add the pages by referring the below steps:
1.Create a new folder, "Pages", under your solution
2.Add a new module,for eg. SampleModule
Module folder structure
3.Add an application page, for eg. SampleApplicaionPage.aspx. The newly added application pages can be found under Layouts Folder.
4.Drag and drop the newly created aspx page into the created "SampleModule", under pages folder.
5.Make necessary changes (module name, required layout, etc.,) in the element.xml file associated with the module as follows:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Pages" Url="$Resources:cmscore,List_Pages_UrlName;">
<File Path="SampleModule\SampleApplicationPage.aspx" Url="SampleApplicationPage.aspx" Type="GhostableInLibrary" ReplaceContent="True">
<Property Name="Sample Module" Value="Sample Module"/>
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/EnterpriseWiki.aspx, EnterpriseWiki"/>
</File>
</Module>
</Elements>
Update the following section in the SampleApplicationPage.aspx
<%# Page Language=”C#”
AutoEventWireUp=”true”
CodeBehind=”ChooseChecklist.aspx.cs”
Inherits=”YourProjectName.YourModuleName.YourClassName”
MasterPageFile=”../_catalogs/masterpage/V4.master” %>
Deploy.
You can view the newly created page under the specified module in Site Contents
Hope this helps.
Final Folder Structure

Related

How to optimize Magento 2 Store in templating level

I am learning Magento 2 and hence, I saw one major issue with Magento 2 is the theme optimization. As we all are facing same issue that Magento 2 theme is not optimized so may I know what steps? what precautions? or what changes and optimization can be done in templating level because rest of the things like default configuration I can do but I don't know the optimization for templating..
What type of optimization are you required? Like layout changes, theme color changes, or some new element want to add home page or category page. banner adding etc.
You can add image banners, product slider or text etc. from Magento admin Content >> Elements >> Pages page.
Regarding, color css changes you can go app/design/frontend/yourthemepackage/yourtheme/web/css/styles.css or you can add your custom theme also. if you add new custom css you need to define this css in default app/design/frontend/yourthemepackage/yourtheme/Magento_Theme/layout/default.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<!------- under head ------------>
<css src="css/Custome.css" />
<!------- under head ------------>
</head>
</page>
if you want to learn more about the magento you can follow up my youtube channel and if you have any issue you can also comment me. I will defiantly help you to learn.
blog: https://php-scripts-form.blogspot.com/
youtube channel : https://www.youtube.com/channel/UChb7DM9SspzrUVh4hnWL50A
As per our discussion i got what you want to do.
you can remove elements and block, containers via xml and also via phtml.
for remove block you can add
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="block.name" remove="true" />
</body>
</page>
And if you want to remove from phtml you can copy template from core theme. vendor/magento/{whichlementyouwanttoreoveendterspecifcmodule}/view/frontend/yourtemeplate.phtml
and copy it in your theme
app/design/frontend/yourthemepackage/yourtheme/yourelement/template/yourtemaplate.phtml
and you can manipulate your content. below i give you a real example for product detail page.
copy core file into your theme :
vendor/magento/module-catalog/view/frontend/templates/product/view/gallery.phtml
your theme path
app/design/frontend/Magento/luma/Magento_Catalog/templates/product/view/gallery.phtml
And after that remove content from gallery.phtml you can see in product detail page gallery will be reomve.
if you understand then good if not so you can connect with me real-time on Skype i will show you via screen share.
Please subscribe my youtube channel. https://www.youtube.com/channel/UChb7DM9SspzrUVh4hnWL50A

Using an Alfresco Share Form Page, How do I upload a new file with metadata?

I'm working With Alfresco Community Edition.
Here's the code I've tried so far: Alfresco-Smalgyax.
I have created an All-in-One Project, to add a new page to the create.. menu. My Page Loads just fine.
I followed, the Adding a menu item to the "Create..." menu in DocLib tutorial, before adding a custom form field and JavaScript to the newly added share page.
I've added a custom field to upload a file to cm:content.
I've added some Javascript to get and set the cm:name and mimetype once an Upload file is chosen.
All the Metadata is correctly ingested. However, the file is not.
Previously I was successfully, able to upload a file with custom data by following the documentation: Processing multipart forms. However, that created a whole new Service endpoint and a custom page that didn't inherit the same look/feel as the rest of the web-application.
The page under create.. has the same look/feel as the rest of the site. But Upload Fails, Is there a way to leverage the Look/feel of the site and upload a file with metadata and set a custom type in Alfresco?
Clarification
The cm:content field has been customized like so:
<field id="cm:content" label-id="" mandatory="true">
<constraint-handlers>
<constraint type="MANDATORY" event="input"
validation-handler="Smalgyax.forms.validation.setNameValue" />
</constraint-handlers>
<control template="/file.ftl">
<control-param name="editorAppearance">explorer</control-param>
</control>
</field>
file.ftl sets the form input element like so:
<input id="${fieldHtmlId}" type="file"
name="${field.name}"
<#if field.disabled>disabled="true"</#if> />
additionally, file.ftl adds custom JavaScript to the page, because I was unable to get it successfully loaded as a separate file using
<forms>
<dependencies>
<js src="/set-name-field.js"/>
</dependencies>
<!-- form definition here -->
As the Alfresco documentation clearly suggests it won't supports the upload feature. The field type shows cm:content that won't accept a file to accept a file even though you have customized and added a explorer option in the code. That is the reason file is not and only content is uploading.
https://docs.alfresco.com/community/tasks/dev-extensions-share-tutorials-add-menuitem-create-menu.html
<field id="cm:content" label-id="">
<control>
<control-param name="editorAppearance">explorer</control-param>
</control>
</field>
For upload a file , you should use the html component like below,
<input type="file" multiple="" name="files[]" class="dnd-file-selection-button">
and the javascript should be same as the file-upload.js and dnd-upload.js.
http://localhost:8180/share/res/components/upload/file-upload.js
http://localhost:8180/share/res/components/upload/dnd-upload.js
Please refer the link below to upload a file through a ajax call.
https://hub.alfresco.com/t5/alfresco-content-services-forum/how-to-upload-a-file-from-a-custom-share-page/td-p/32361

Liferay custom portlet permission label missing

I've followed the instructions from this tutorial to introduce a new portlet level permission for my custom portlet.
In the resource-action-mapping XML there is a new action-key called PARTNER_ADMIN_CONTRACTING, and I've added the following line to the Language.properties file:
action.PARTNER_ADMIN_CONTRACTING=Admin contracting
On the Define permissions tab, it still shows the label key, not the value:
What's missing?
You have to add the action.PARTNER_ADMIN_CONTRACTING=Admin contracting language key to the portal resource bundle, because the Control Panel does not look for the translation in your portlet. You can use the language hook feature do to this:
Create a liferay-hook.xml in your docroot/WEB-INF directory:
<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">
<hook>
<language-properties>content-portal/Language.properties</language-properties>
</hook>
Create docroot/WEB-INF/src/content-portal/Language.properties:
action.PARTNER_ADMIN_CONTRACTING=Admin contracting
This should work!

Automatically add tag to uploaded document in sharepoint

My environment is sharepoint 2010 and vs 2010.
I already have an OOTB document library that I am using and I wanted to know how I can add a tag or keyword to a METADATA column.
I am using the same document library in all subsites and so would like to tag the uploaded document with the name of the current site (ie if it's being used in a subsite, that subsite's name would be the tag).
Would I need to build a custom document library or some sort of add-on webpart that attaches to the existing document library?
If you could provide some code samples if any that would be appreciated.
thanks,
KS
If you are starting from scratch you can create a custom content type based on the build in content type Document (a child content type of Document). Add a custom field to your content type. For more information regarding creating content types look here: http://msdn.microsoft.com/en-us/library/gg295290.aspx
A content type can also have a custom event receiver for ItemAdding, ItemUpdated etc. Look at the xml below:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID="0x010100xxxxxx"
Name="MyContentType"
Group="My custom group" Version="0" Inherits="True" Overwrite="TRUE" >
<FieldRefs>
<FieldRef ID="{AC8A823D-EB2F-4D4D-8BF0-14CACA509539}" Name="myMetadataField" Required="FALSE" />
</FieldRefs>
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
<spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events">
<Receiver>
<SequenceNumber>1010</SequenceNumber>
<Name>HandoverOffshore_ItemAddedReceiver</Name>
<Type>ItemAdded</Type>
<Assembly>MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=79315a88caec227a</Assembly>
<Class>MyAssembly.CustomEventReceivers</Class>
</Receiver>
</spe:Receivers>
</XmlDocument>
</XmlDocuments>
</ContentType>
</Elements>
Then you'll have to create the event receiver class witch handles the custom event:
public class HandoverOffshoreEventReceivers : SPItemEventReceiver
{
public override void ItemAdded(SPItemEventProperties properties)
{
// your code for updating metadata field here...
}
}
Then you deploy this to your site collection and add this content type to all your libraries. Also set this as the default content type in all libraries.
If you are creating many libraries you should consider to create a custom library definition based on this content type.
If you want this custom event fired for existing documents you'll have to change their content type to the new one you created here.
Note that document library content types are child content types of the site collection content types.

Change the Category for Web Part to be displayed

In Sharepoint 2010, is there any way to change the category where custom web parts created in VS2010 to be placed.
VS2010 is putting the custom web part in "Custom" category by default. I'm curious that, is there any way for us to change it, for example "MyCustomWebParts" category.
incase I couldn't made myself clear:
You can change file Elements.xml. Into File tag add line:
<Property Name="Group" Value="MyCustomWebPart" />
or
Select “Site Actions” >> “Site Settings” >> “Modify All Site Settings”.
Click the “Web Parts” link in the Galleries group.
Open your webpart for edit.
In the Group section, check the “Specify your own value” option and type in a group name (e.g. MyCustomWebParts)
There is! In the .webpart file, under the Module/File path, add a tag like this:
<Property Name="Group" Value="My Custom Group"/>
That's all there is to it!