Giter Site home page Giter Site logo

Comments (6)

stalniy avatar stalniy commented on May 5, 2024

Not the best idea because template may be used by several blocks.
If you want to determine which template is related to some block class you may "Template Path Hits" (http://www.magentocommerce.com/blog/template-path-hints-tutorial-video/).

from magento2.

FiveDigital avatar FiveDigital commented on May 5, 2024

Most templates are used by only one block. I have requested this because I'd like to be able to ctrl click function calls like $this->doSomething() in templates in my IDE.

from magento2.

stalniy avatar stalniy commented on May 5, 2024

Anyway idea is bad. Just think, what will happen if somebody rewrites this block using Magento rewrite system?

from magento2.

magento-team avatar magento-team commented on May 5, 2024

@FiveDigital
Thank you for proposing an interesting improvement.
Indeed, if to search among all PHTML templates in the system, notations @var $this and @see are already used ~50/50.
It does make sense to standardize block class(es) hinting. Proposal of declaring a primary block class using @var $this Primary_Block_Class and optionally additional classes using @see Additional_Block_Class has been sent to the technical leads for examination. As soon as there are any updates to the proposal state (rejected, accepted, adopted), corresponding update will be posted to the GutHub ticket.

@stalniy
Yes, you're right, that relation between blocks and templates is not 1 to 1, multiple blocks can utilize the same template. However, it does not contradict to the hinting of a primary and additional block classes.

from magento2.

FiveDigital avatar FiveDigital commented on May 5, 2024

I know that @see is used in many templates, but that doesn't enable code completion/code hinting. I'm really a fan of being able to ctrl-click functions and I'm using this in templates, too. When we create/override templates for shop we develop in our company, I assure everyone add a @var $this comment. In fact, I'm always adding comments like /* @var $products Mage_Catalog_Model_Resource_Product_Collection everytime when writing code like $products = Mage::getResourceModel('catalog/product_collection') to be able to auto complete function and jump easily in the core code.

from magento2.

magento-team avatar magento-team commented on May 5, 2024

The proposal was approved by the technical leads and included into Magento 2 coding standards. @var $this Primary_Block_Class is intended for primary class definition and @see Additional_Block_Class for additional classes. The task about updating exisitng templates was added to Magento 2 backlog.

@FiveDigital , thank you for the proposal.

from magento2.

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.