pnp / PnP-Sites-Core

Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Other
415 stars 643 forks source link

When saving modern page leave the ability to have empty title #1365

Closed Saulius-Laurinaitis closed 6 years ago

Saulius-Laurinaitis commented 6 years ago

Hi, there would be a nice feature to save a page with empty title, it is very important for creating a page with Guid name where after user saving it would be changed. Improvement would include a very small change in function ClientSidePage.Save.

item[ClientSidePage.Title] = this.pageTitle

Title then can be updated by user.

Category

[X] Enhancement

Environment

[X] Office 365 / SharePoint Online

Thanks Saulius

jansenbe commented 6 years ago

I've just pushed a change that allows you to set the page title using the pages object model, so you can load pages and update them. I currently do not allow to set an empty page title as that's also not allowed in the UI and we strive for a consistent experience. What's the key scenario for being able to set an empty page title?

Saulius-Laurinaitis commented 6 years ago

The scenario is very simple: provision pages using the template, e.q. I have news page template with a special layout and components on the page. User clicks on the button, page is provisioned by the template, plus some customization and redirects user to the new created page with the guid in the name (as current UI does), then user enter title and current UI updates name automatically by title, but if title is set then on title update name is not updated. Current UI also allows to create a page without the title. Hopefully it makes sense. thanks

jansenbe commented 6 years ago

So you want the pagename to be updated when the title changes....I'll need to think about this and check if there are supported API's to this. In modern team sites the noscript option in on by default which will prevent you from calling the move api to move from temp.aspx to final.aspx as filename.

You indeed can get a page with empty title using the UI, but that's not the default flow I would say. What's the case where you really want to have an empty page title?

Saulius-Laurinaitis commented 6 years ago

no no, all is there already - try adding new modern page manually, then leave title empty, but add a web part to the page, wait for few seconds and check the url change, then add title and wait for few seconds and see how url changes to the nice one by title. So this is what I'm trying to replicate, e.g. I'm creating a page with guid in the name, but when user updates title, then it gets nice url. Just one thing I was thinking to leave title empty, by default, unless developer is explicitly setting it wen creating a page. If you think that it against your practice then that's fine, I will just then maintain may own branch of the code.

Thanks Saulius

jansenbe commented 6 years ago

I know it's already there :-)....point is do we have a "supported" API to this programmatically. It's not because SPO uses a particular API that it's supported for the developers to use it. Some API's are internal only and can change at any moment, so using them could break your code at any time.

Saulius-Laurinaitis commented 6 years ago

oh, ok, I understand what you mean :) that's a valid point, but still a nice feature I think and hopefully it will continue to work! I remember from my experience that some of my code was working because SP had a bug and after fix it just stopped :) in the future could be the same here.

jansenbe commented 6 years ago

Closing now. Ability to control Title will be in October release