Git Product home page Git Product logo

Comments (6)

arambalakjian avatar arambalakjian commented on July 30, 2024

I've just realised this is a little more complex when you actually want to use $Title as a front-end field. If $Name is meant for CMS use and the $Title is meant for front end, then the GridFieldAddExistingSearchButton needs to use $Name rather than $Title.

Currently you would have to do the following:

        $fields->addFieldToTab('Root.Main', new TextField('Title', 'Name (CMS Use Only)'),'ManyMany[BlockArea]');
        $fields->addFieldToTab('Root.Main', new TextField('Name', 'Title'),'ManyMany[BlockArea]');

And then use $Name in the front end as though it were $Title...

Pretty horrible :)

from silverstripe-blocks.

arambalakjian avatar arambalakjian commented on July 30, 2024

Also related to this is that the CMS breadcrumbs do not display the name of the block you are currently on, as they also rely on a $Title field too.

In all honesty, I'm not convinced that the semantic benefits of removing Block::$Title outweigh the complications and issues that it causes elsewhere.

As I understand it all DataObjects should have a $Title field anyway, whether it's used on the front-end or not, otherwise you start getting into issues where it's assumed to exist.

from silverstripe-blocks.

micschk avatar micschk commented on July 30, 2024

Hi Aram, Shea,

I'm the one responsible for changing the Title to Name, with the reasoning
as described. I haven't noticed the necessity for a Title field because I
added a fallback getTitle while developing, like you did. For obvious
reasons this didn't make it into the merged version.

However, I'd vote against just adding back the title field, as it's a wrong
assumption that all blocks necessarily need a title. For
GridFieldAddExistingSearchButton, we'd better make a Fix/PR adding
functionality to pick the searchfield to that module. As for the
breadcrumbs, we'd have to look into that as well, as DataObjects shouldn't
to my opinion be required to have a Title by default. If they are, that's
something to fix in the framework instead of building on onto a wrong
assumption.

from silverstripe-blocks.

sheadawson avatar sheadawson commented on July 30, 2024

Thanks for you input on this guys. I was really on the fence with the idea of adding the Name field or not, there's good arguments on both sides.

With my use of Blocks I've always just had Title for use in both front and backend and that has been fine. And now upgrading my projects to use Blocks 1.0 I am ending up just using the Name field as the Title field in the frontend and backend (I have no need for a second field here).

There is a getTitle method on DataObject that falls back to Name but it's obviously not getting used in all cases.

I'm going to agree with Aram here, we're creating more issues than it's worth and I'm happy to revert back to using Title. If anyone needs a separate field for frontend they can add a Heading field.

Will push the changes up shortly

from silverstripe-blocks.

sheadawson avatar sheadawson commented on July 30, 2024

Reverted in 684d675 Released in 1.0.1

from silverstripe-blocks.

arambalakjian avatar arambalakjian commented on July 30, 2024

Great thanks guys, I agree arguments on both sides but until the other bits become more flexible it seems like the best bet.

from silverstripe-blocks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.