I am creating a custom field in Joomla. I have this code:
class JFormFieldEmbed extends JFormField {
protected $type = 'Embed';
public function getInput() {
$out='';
$out.='<pre>'.print_r($this->form,true).'</pre>';
return $out;
}
}
I see in the output $form->data that contains the title but is a protected object.
How do I get Joomla module title in custom fields?
UPDATE:
By now my solution with JavaScript:
class JFormFieldEmbed extends JFormField {
protected $type = 'Embed';
public function getInput() {
$script1=htmlentities('<script type="text/javascript" src="'.JURI::root().'modules/mod_mydodule/js/script.js" data-title="');
$script2=htmlentities('"></script>');
return<<<EOD
<div id="embedmymodule"></div>
<script type="text/javascript">
jQuery(function($){
$("#embedmymodule").html('$script1'+encodeURIComponent( $('[name=\"jform[title]\"]').val() )+'$script2');
});
</script>
EOD;
}
}
This code will output the module title:
$module->title
Found the answer in the source files of Joomla:
echo $this->form->getValue('title');
Related
<?php
namespace App\Http\Livewire\Components;
use Livewire\Component;
class PropertyCard extends Component
{
public $title;
public function mount($title)
{
$this->title = $title;
}
public function render()
{
return view('livewire.components.property-card');
}
}
This is Livewire controller
<livewire:components.property-card title="Test 1" />
This livewire component.
Error is
Unable to resolve dependency [Parameter #0 [ $title ]] in class App\Http\Livewire\Components\PropertyCard (View: D:\Projects\Laravel\clemsonporter.com\resources\views\livewire\new-launch-page.blade.php)
It seems you have missed a double colon (:) before title.
<livewire:components.property-card :title="Test 1"/>
Read more on parameters here.
Public properties dont need to be set in mount. Livewire will automatically detect them. The following snippet does exactly the same as your code:
class PropertyCard extends Component
{
public $title;
public function render()
{
return view('livewire.components.property-card');
}
}
But that's besides the error you're experiencing. Qirel is correct, there's some component where you aren't setting the title property.
muestramodal.blade.ph
<x-button.link wire:click="edit">Edit</x-button.link>
<x-modal.dialog wire:model="edit">
<x-slot name="title">Edit transaction</x-slot>
<x-slot name="content">Hola</x-slot>
<x-slot name="footer">
</x-slot>
</x-modal.dialog>
muestramodal.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Muestramodal extends Component
{
public $showEditModal = false;
public function edit()
{
$this->showEditModal = true;
}
public function render()
{
return view('livewire.muestramodal');
}
}
Why is not shown modal , with click event button???
Several hours trying to solve this problem.....
Please , can anyone help me? Thanks
need to update your muestramodal.php and extends LivewireUI\Modal\ModalComponent;
<?php
namespace App\Http\Livewire;
LivewireUI\Modal\ModalComponent;
class Muestramodal extends ModalComponent
{
public $showEditModal = false;
public function edit()
{
$this->showEditModal = true;
}
public function render()
{
return view('livewire.muestramodal');
}
}
how can i manage url in address bar after posting a form or after loading a page after submission.
Is it possible to manage with routing ?
<?php
public function index(){
$this->load->view('login');
}
public function login_process(){
....... code......
if($login==true){
$this->load->view('dashboard'); // Url is not changing but view is loaded
}else{
$this->load->view('login');
}
}
?>
Hope this will help you :
Use redirect() method from url helper , make sure you load it in controller or in autoload.php
public function login_process()
{
....... code......
if($login === TRUE)
{
redirect('controller_name/dashboard','refresh');
/*$this->load->view('dashboard'); */
}
else
{
redirect('controller_name/index','refresh');
/*$this->load->view('login');*/
}
}
For more :https://www.codeigniter.com/user_guide/helpers/url_helper.html#redirect
You should create another method called dashboard and you should redirect to it like following
class Example_Controller extends CI_Controller {
public function index(){
$this->load->view('login');
}
public function dashboard(){
$this->load->view('dashboard');
}
public function login_process(){
// Your Code
redirect('Example_Controller/' . (($login==true) ? 'dashboard' : 'index'));
}
}
replace Example_Controller with your controller name.
and add following lines in routes.php
$route['login'] = 'Example_Controller/index';
$route['dashboard'] = 'Example_Controller/dashboard';
I am integrate custom template to widget but its doesn't show the template data. below is my code
community/Sample/Productslider/etc/widget.xml
<widgets>
<productslider_bestseller type="productslider/bestseller" translate="product slider option" module="productslider">
<name>Best Seller Product</name>
<description type="desc">Enable the Best Seller Product Widget</description>
<parameters>
<template>
<required>1</required>
<visible>1</visible>
<label>Template</label>
<type>select</type>
<values>
<best-seller translate="label">
<value>productslider/best-seller.phtml</value>
<label>Best Seller</label>
</best-seller>
</values>
</template>
</parameters>
</productslider_bestseller>
</widgets>
community/Sample/Productslider/Block/Bestseller.php
class Sample_Productslider_Block_Bestseller extends Mage_Core_Block_Abstract implements Mage_Widget_Block_Interface
{
protected function _construct()
{
parent::_construct();
}
protected function _toHtml()
{
$pageTitle = '';
$headBlock = $this->getLayout()->getBlock('head');
if ($headBlock) {
$pageTitle = $headBlock->getTitle();
}
$html = "test";
$this->assign('best-seller', $html);
return parent::_toHtml();
}
}
fronted/base/default/template/productslider/best-seller.phtml
echo $html;
It show blank page in front when i include widget in cms page.
Any one can help me to find out the issue in my code.
Thanks
To me your issue consists in extending Mage_Core_Block_Abstract in which _toHtml method return a void string.
Just set your template in your constructor and extends Mage_Core_Block_Template instead of Mage_Core_Block_Abstract
You can assign a template to a block via the constructor (example taken from core file : /app/code/core/Mage/Catalog/Block/Layer/State.php:43)
public function __construct()
{
parent::__construct();
$this->setTemplate('catalog/layer/state.phtml');
}
So you would have to do something like this in your __contruct
$this->setTemplate('productslider/best-seller.phtml');
But what you seems to have trouble with is passing data to this template ?
Then, make is as you would in any other template :
In your block :
public function getSomeExtraHtml(){
return 'test';
}
In the template :
<?php echo $this->getSomeExtraHtml() ?>
You'll have to set the template in your Block Class
protected function _toHtml()
{
$this->setTemplate('my_module/widget.phtml');
return parent::_toHtml();
}
Create a folder under
app/design/frontend/your_theme/default/my_module and add your html file
I want to add a custom tab to the order page in the admin of magento. Is there a way to do this with a simple override?
Assuming you know how to do a module, here are the steps you need to perform:
layout update: in your admin's xml layout file you want to "listening" to the admin's order view rendering handle and add your tab:
<layout>
<adminhtml_sales_order_view>
<reference name="sales_order_tabs">
<action method="addTab"><name>the_name_of_your_tab</name><block>the_block_alias_of_your_module/path_to_your_tab_file</block></action>
</reference>
</adminhtml_sales_order_view>
</layout>
the tab file: I generally try to respect Magento's folder structure, so this file would be in app/code/local-or-community/YourNamespace/YourModule/Block/Adminhtml/Order/View/Tab/File.php and will have at least:
<?php
class YourNamespace_YourModule_Block_Adminhtml_Order_View_Tab_File
extends Mage_Adminhtml_Block_Template
implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
protected $_chat = null;
protected function _construct()
{
parent::_construct();
$this->setTemplate('yourmodule/order/view/tab/file.phtml');
}
public function getTabLabel() {
return $this->__('Tab label');
}
public function getTabTitle() {
return $this->__('Tab title');
}
public function canShowTab() {
return true;
}
public function isHidden() {
return false;
}
public function getOrder(){
return Mage::registry('current_order');
}
The .phtml file, which has to respect the path you specified in the block's __construct(), and should hace something like:
<div class="entry-edit">
<div class="entry-edit-head">
<h4><?php echo $this->__('a title'); ?></h4>
</div>
<div class="fieldset fieldset-wide">
the content you want to show
</div>
</div>
Hope That Helps