How to
- Categories: How to<td><a href="<?= $escaper->escapeUrl($block->getUrl('blog/manage/edit', ['id'=>$escaper->escapeHtml($blog->getId())]))?>"><?= __('Edit') ?></a><
- Categories: How to
We will create Blog.php under Model Folder
- Categories: How to
Create the Block:
Inside the
Block
directory, create a Directory Add and PHP file namedAdd.php
.View this link for form validation method and this
Include form action from block
return $this->getUrl('training/post/addpost');
Add form key for security
<?php echo $block->getBlockHtml('formkey'); ?>
Add valition
data-mage-init='{"validation": {}}'
- Categories: How to
In this blog, I'll guide you through the process of creating a Block, Controller, Template file, and their corresponding layout files.
I hope you must be a developer reading this blog so i would give you tips how you can improve your efficacy.
If you are using a PHPSTORM then you can use live template that will make your work much smoother and less work hasle.
Create A Controller:
<?php
namespace Anees\Training\Controller\Index;
use Magento\Framework\App\Action\Action;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Context;
class Index extends Action
{
/**
* @var PageFactory
*/
protected $pageFactory;
/**
* @param Context $context
* @param PageFactory $pageFactory
*/
public - Categories: How to
I will make it very simple sweet and short. No long boring text. Just to the point.
Lets start!
Magento 2 only need two files to register and initialize a module.
-
registration.php: This file is located in the root directory of your module (
app/code/Anees/Training/registration.php
). It uses a Magento function to register the module with the framework. -
etc/module.xml: This file is located within the
etc
folder of your module (app/code/Anees/Training/etc/module.xml
). It defines the module's name, setup version, and any dependencies it might have.
After adding above two files run command
bin/magento module:enable Anees_Training
Remember this is just a start. Magic will happen
-
- Apr 02 2024
Magento2: Create list with pager in frontend
Categories: How tohttps://webkul.com/blog/magento2-create-list-with-pager-in-frontend/
So first you have to check where you are getting collection. Most of time its coming from block and this blog also share how to do it when collection is coming from block.
Now go to your block file and add a _prepareLayout() function. This function render the layout of page as its visible from its name like we can set page title and other things also this function runs automatically.
See below function.
protected function _prepareLayout()
{
parent::_prepareLayout();
$this->pageConfig->getTitle()->set(__('My Reward History'));
// Assuming $macAddress is available, get records for the given MAC address
$blockss_c = $this->getLayout()->createBlock('\Motoris\Vehiclelookup\Block\Cookie');
$macAddress = $blockss_c->get('customer_veh');
$records - Mar 19 2024
Magento 2 Forms
Categories: How toLearn Magento 2 form Validation
https://www.thecoachsmb.com/a-complete-guide-on-magento-2-form-validation/
and
https://magecomp.com/blog/create-custom-form-in-magento-2-frontend/
Here is simple form example that make an ajax call
<?php
/** @var \Mageleap\Customform\Block\Index\Index $block */
?>
<div class="row"></div>
<form id="your-form-id" method="post" action="test.php" data-hasrequired="<?= $escaper->escapeHtmlAttr(__('* Required Fields')) ?>">
<div class="row">
<div class="col-md-6">
<div class="field city required">
<label class="label" - Mar 06 2024
Magento 2 Setup
Categories: How toA step by step guide for Magento 2 setup on hosting or ubuntu.
- Sep 06 2023
PhpStorm reset evaluation license/period
Categories: How toStep # 1:
Make Sure that Hidden file are visible if they are not already.
- Go to C drive or where your windows is located.
- Click on view from Top.
- Select all folder and hide selected button.
Step # 2:
Go to users and select your computer name. As you can see in My case its HP.
Click on AppData.