Joomla - Custom Field doesn't show-up on Edit/Update - joomla

I've followed this Tutorial to add a custom field to the article content type and I was successful to make a new one with adding the following code:
In File : root/administrator/components/com_content/models/forms/article.xml
Code :
<field name="newText" type="editor" class="inputbox"
label="COM_CONTENT_FIELD_ARTICLETEXT_LABEL"
description="COM_CONTENT_FIELD_ARTICLETEXT_DESC"
filter="ContentHelper::filterText" buttons="true" />
In File : root/administrator/components/com_content/views/article/tmpl/edit.php
Code :
//Our new textbox
<div class="clr"></div>
<label>Article Text - New Text</label>
<div class="clr"></div>
<?php echo $this->form->getInput('newText'); ?>
and altered Database to add a new column for that new field.
ALTER TABLE 'j_content' ADD 'newText' VARCHAR( 255 ) NOT NULL;
On Article posting the data is successfully getting stored in Database.
The new custom field is visible when I'm posting a brand new article. But when I'm editing/updating the same new post, that newly added field is missing.
Is there a way to get this field even when we are editing the post/article.

Please, never overwrite core files or change the core database! This is not a good tutorial because it is not update-safe.
If you need additional fields for your content items, use a special core extension for this instead.
I recommend this one:
http://fieldsattach.com/. This method is update-safe.

Related

How to display custom data in Mgt Person in SPFX

I want to display custom data which is coming from an API which will have data in 4 lines in Person Mgt,
I don't want to use default data from personquery, so how can I pass list of people's data in the Person Mgt also by default it shows data in just three lines but I want to display 4 details of an individual in 4 different lines in SPFX.
I've provided sample implementation of the code,
public render(): React.ReactElement<IMgtComponentsProps> {
return (
<Person
personQuery="me"
//personDetails={personDetails}
view={ViewType.threelines}
fetchImage={true}
avatarType={avatarType.photo}
personCardInteraction={PersonCardInteraction.hover} />
);
}
I'll be having similar type of custom data as shown below so I want to show these details as per user.
const personDetails = {
displayName: 'Bill Gates',
mail: 'nikola#contoso.com',
role:'Developer',
community:'Software Enginnering'
}
I tried passing this object inside personDetails property of Person but it's not working.
Currently a fourth line of data is only support via a custom rendering template
Here's an example of that using the raw web component as opposed to the React Wrapper.
<mgt-person class="my-person" person-query="me">
<template>
<div>
Hello, my name is: {{person.displayName}} <br>
{{person.role}} <br>
{{person.community}} <br>
{{person.mail}}
</div>
</template>
<template data-type="loading">
Loading
</template>
</mgt-person>
const person = document.querySelector('.my-person');
person.personDetails = {
displayName: 'Bill Gates',
mail: 'nikola#contoso.com',
role: 'Developer',
community: 'Software Enginnering'
};
With the existing three line view you can map each of the lines to your custom properties, assuming you have the above custom data being passed correctly you can have the component render the chosen properties on each line.
<mgt-person
class="my-person"
view="threeLines"
line2-property="role"
line2-property="community"
person-card="hover"
fetch-image>
</mgt-person>
The good news for the four-line case is that we are adding that to the library as part of our v3 release which is currently being worked on.

How to add 'Company Name' in customer register and billing info

I've been trying to add 'company name' on customer register and onepage checkout but unsuccessfully so far. I tried https://magento.stackexchange.com/questions/15847/add-company-name-to-billing-shipping-dropdown-in-magento but it didn't help at all.
I can't believe there isn't a simple way of doing that.
The company field is already part of the address entity in Magento, if it isn't showing on register and checkout forms you'll need to update the templates to include it.
I recommend that you look in either the base/default or rwd/default theme and look at:
checkout/onepage/shipping.phtml
persistent/customer/form/register.phtml
persistent/checkout/onepage/billing.phtml
You should see company in there and can copy that into your active theme.
Hope that helps!
Adding a new field to Magento new customer registration can be done in 4 simple steps. Follow the steps given below to get done with it.
Step 1: We have to add php and .html form elements that are necessary to create new input boxes for each additional field in register.phtml.
<div class="input-box">
<label for=”company_name”><?php echo $this->__('Company Name') ?></label><br/>
<input type="text" name="company_name" id="company_name" value="<?php echo $this->htmlEscape($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company Name') ?>" class="input-text" />
</div>
Step 2: We need to add elements under “getDefaultEntities()” in Setup.php (path: /app/code/core/Mage/Customer/Model/Entity/), one for each additional field created above:
company_name' => array(
'label' => 'Company Name',
'required' => false,
'sort_order' => 64,
),
Step 3: Add to the content of $customer in AccountController.php (path: /app/code/core/Mage/Customer/controllers/) by grabbing the new fields from posted info, in the createPostAction() function:
$customer = Mage::getModel('customer/customer')->
setCompany($this->getRequest()->getPost('company_name'));
Step 4: Finally, we will need to add database records to table eav_attribute, corresponding to the newly created fields. The idea is to add to the associated data model, where newly defined model data is entered as the “attribute_code”, with the corresponding entity_type_id (which for this data happens to be ‘1’).
Using your favourite SQL editor (i.e. phpMySQL or sqlYog — highly recommended), execute the following SQL statement for each field created above (replacing ‘company’ and ‘Company Name’ with the respective field name information as required):
INSERT INTO eav_attribute (entity_type_id, attribute_code, backend_type, frontend_input, frontend_label, is_global,is_visible, is_required, is_configurable, is_filterable_in_search) VALUES(’1′, ‘company’, ‘varchar’, ‘text’, ‘Company Name’, ’1′, ’1′, ’0′, ’1′, ’1′);

Set visibility of form input in thymleaf using th:if

I am new to thymeleaf and I have this problem.
I have a form to add and edit products.
From the controller I set request mapping to access this form view using
#RequestMapping("/products/add")
and
#RequestMapping("/products/edit/{id}")
I have a field in products ,Date endPromotion.
I want this input block that has endPromotion field to be shown only in edit mode.
How can I do that using thymleaf condition?
i tried somthing like
<div th:if="${|/products/{action}(action='edit')|}"> .. valid html code ... </div>
but it doesn't work
This should do the trick
<div th:if="${#strings.contains(#httpServletRequest.requestURI, '/products/edit/')}">
some content
</div>

Add new field in bundle item option in admin section

I am new bie in magento.I am creating a bundle product from admin section .when I add the bundle item there is only the title field for information but I need to add one more field for the description like I created a bundle item for computers but I need to show description about it .
Please help .my requirement is to add new field for description along with the title in bundle item option.
any help will be appreciated .
you can add extra field to magento bundle products by editing app\design\adminhtml\default\default\template\catalog\product\edit\options\type\select.phtml and few database changes.
EDIT:
first we have to add our custom field to catalog_product_option_type_value table in the database, using a instraller script
<?php
/* #var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$installer->getConnection()
->addColumn($installer->getTable('catalog/product_option_type_value'), 'your_custom_field_name’, 'VARCHAR(128) NULL');
$installer->endSetup();
then copy the file in location app\design\adminhtml\default\default\template\catalog\product\edit\options\type\select.phtml
to app\design\adminhtml\default\default\template\companyname\catalog\product\edit\options\type\select.phtml. override the core file
Rewrite: ‘Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Select’ block and replace constructor file in it by indicating our phtml file
public function __construct()
{
parent::__construct();
$this->setTemplate('companyname/catalog/product/edit/options/type/select.phtml');
$this->setCanEditPrice(true);
$this->setCanReadPrice(true);
}
open companyname/catalog/product/edit/options/type/select.phtml ile in OptionTemplateSelect varilable in tag we add the line: under 'sort order' field
'<th class="type-title"><?php echo Mage::helper('catalog')->__('your_custom_field_name') ?></th>'+
Add OptionTemplateSelectRow tag to the variable:
'<td><input type="text" class="input-text select-type-details" id="product_option_{{id}}_select_{{select_id}}_title" name="product[options][{{id}}][values][{{select_id}}][your_custom_field_name]" value="{{your_custom_field_name}}">{{checkboxScopeTitle}}</td>'+
now check in backend you should see the custom field by now. to make it required you can add required-entry class to above input field
now for retrieve values from database re-write the block:
Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option
In: 'getOptionValues()' method, cycle: foreach ($option->getValues() as $_value) {
add new key: 'your_custom_field_name' to the variable: $value and the value for it: $_value->getYourCustomField();
now custom field will appear in database
In order for the new attribute to appear on the frontend rewrite the class: Mage_Catalog_Block_Product_View_Options_Type_Select and add the newly added attribute to it. But be aware that depending on the type of Custom Options there different kinds of htmls generate.
please refer this article for more details

Server side validation in module setting page in backend joomla

I am using joomla 2.5, i am working on joomla module, i want to perform server side custom form validation at backend setting page in module. I have checked joomla forums , but they all explained according to component , i strictly need to do it in module . I am new in joomla . Please explain the method.
Try this,
First of all you can't do a wide variety of validations like components forms in module params without hacking the core.
the available options are limiting INT,RAW data string only.
you can use the last option of module params called filter. Details take a look at this.
<field name="myintvalue" type="text" default="8" label="Enter some text" description="Enter some description" filter="integer" />
<field name="myhtmlvalue" type="text" default="" label="Enter some text" description="Enter some description" filter="raw" />
Alternate Options.
You can create a custom rule for validation. For example your module name is mod_mymodule:
Add addrulepath attribute to the fieldset in the .xml file:
addrulepath="modules/mod_mymodule"
This will be the path to the custom rule folder.
Add validate attribute to the field with the name of the rule file:
validate="testint"
This will give us the file testint.php.
Create the rule file testint.php and put it to the path specified in the addrulepath attribute. So the full path will be:
administrator/modules/mod_mymodule/testint.php
Here is a simple validation rule class:
class JFormRuleTestint extends JFormRule
{
public function test(&$element, $value, $group = null, &$input = null, &$form = null)
{
return ((int)$value > 0 && (int)$value < 2);
}
}
it should extend JFormRule class and you will need only one method, called test. $value will contain the input from the field. Here we are testing it to be integer between 0 and 2.
Hope its helps..

Resources