templates - magento 2 custom phtml page -


having got myself acquainted (enough) magento 1.9, , able make customisations required, i've been told once it's out, we're moving magento v2.0. having found differences in file structure, believe can see place code custom pages use, how can add page project static block later use? previously, method used follows (i realise may not follow best practise, worked):

  1. create element folder within theme or core templates directory. eg. /app/design/frontend/<theme>/default/template/myelement/mypage.phtml
  2. add page/element static block using following in content editor:

    {{block type="<theme>/default" template="myelement/mypage.phtml"}}

this block can added category pages required.

in magento 2, have tried believe required, replicating file structure , adding phtml files this, template file resides in:

/app/code/<supplier>/<module>/view/frontend/templates/mypage.phtml 

adding content editor following:

{{block type="<supplier>/<module>" template="mypage.phtml"}} 

unfortunately, not display intended page (element). doesn't display calling "{{block" entry either, happens when line invalid, can assume i'm missing link template.

if can offer assistance this, grateful.

edit: continued research on has led me following assumptions:

  1. magento 2 requires more new .phtml page, simple customizations.
  2. i'm still missing something.....

having gone through 3 different tutorials on creating new modules magento 2, each providing different methods, fundamentally being same thing, have believe should code elements make new .phtml template display in static block.

this has led additional problem though. while have required code, cannot add module. adding module etc/config.php, suggested in 2 out of 3 tutorials, crashed m2, both admin , frontend when try clear cache. case after manually clearing cache folders in var directory.

also, still unable add .phtml template file static block or page using content editor.

not hair left pull out here, looking help! in advance

share|improve question

there few samples on github, including https://github.com/magento/magento2-samples/tree/master/sample-module-newpage shows module adding new page simple phtml template file. example not use cms content editing - sample based on using layout files.

you mentioned getting crashes. need more details on one. if got solved, update question , accept response close out? thx!

share|improve answer
    
work on project has been temporarily halted. re-visiting later. continuing magento 1.9 , migrating magento 2 further down line. input though, keep in mind when revisit magento 2. – user3867548 aug 12 '15 @ 14:41

you should try "class" instead of "type". code should like.

{{block class="<package>\<module>\block\myblock" template="mypage.phtml"}} 
share|improve answer
    
thanks aziz. unfortunately appears that, while answer may correct, i'm still missing something. – user3867548 jun 22 '15 @ 15:16
    
thanks aziz. while i'm sure answer right, appears make sense, must still missing something. have gone through tutorials creating modules (overkill want, might learn). when adding module config.php suggested in tutorials, magento2 crashes (admin , frontend). using full module file structure, using code suggested prevents whole block displaying. thoughts? – user3867548 jun 22 '15 @ 15:26

you should try "vendername_modulename::myelement/mypage.phtml" instead of "myelement/mypage.phtml". code should like.

 {{block class="vendernamemodulename\block\myblock" template="vendername_modulename::myelement/mypage.phtml"}} 
share|improve answer

your answer

 
discard

posting answer, agree privacy policy , terms of service.

not answer you're looking for? browse other questions tagged or ask own question.

Comments