add custom field in com_category joomla 3.x - php

i need to add a field into component com_categories, this is for i need add new values in categories, for example these are the archives that i modified:
Joomla 3.1.5
administrator\components\com_categories\views\category\tmp\
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('subtitulo'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('subtitulo'); ?>
</div>
</div>
and too in this file:
administrator\components\com_categories\models\forms\category.xml
<field
name="subtitulo"
type="textarea"
label="subtitulo"
description="USE ESTE SUBTITULO"
rows ="4" cols="6" filter="raw"
/>
So, the new field appear in backend administrator but when i save the new data incustom field... disapear!
The problem would be save the new field into Database or another method, because when i modify the template (default_items.php) can i se the changes i do, the new field if is saved must be appear using
<?php
print_r($this);
?>
but dont appear the new data (subtitulo), whats wrong??, how can i do to add new field in mod_categories and access it.

Related

What is required to work PHP post form method?

I am new to php so help me to make it work. Required action completed by opening the ready.php file but entered form data is not displaying in ready.php file.
i AM USING THIS CODE in index.php for form.
<form method="post" action="ready.php">
<div class="enter-name">
<input class="animated pulse infinite" type="name" required="" maxlength="50" name="n" placeholder="๐Ÿ‘‰ Enter Your Name Here">
<button class="btn animated shake infinite" type="submit"><span>๐Ÿ‘‰</span> Go</button>
</div>
code for ready.php
<figure>
<h1 class="naming"></h1>
<h1 class="naming"></h1>
<h1 class="naming"></h1>
<h1 class="naming"></h1>
<h1 class="naming"></h1>
or
<div class="busi"><br><img src="4.png" height="35px" width="35px"/>
I am not getting what the problem with that.
You don't need a database connection for this, but you do need to be running/have access to some sort of server with php functionality (apache is a good choice).
Regarding the code, I'm no expert, but you could try adding the "name" attribute, because that's what the php script is going to look for. I added it below (name = "name"). You also need to change the input type to text (type="text"):
<input class="animated pulse infinite" type="text" name="name" required="" maxlength="50" name="n" placeholder="๐Ÿ‘‰ Enter Your Name Here">
in your php script, you can find the name variable from the textbox by using this code:
$myName = $_POST['name'];
The name will be inside the variable $myName.
Good luck!
i resolve my above problem by applying this code
<?php echo $_REQUEST['n'];?>

Set default value in form field

I have a form in a Joomla component in which the user needs to select a country and then a city depending on the country selected. In my case I only need one country. How can I edit or replace the code below to set the country to a default value and remove it from the form?
<div class="form-group">
<label for="submit-location"><?php echo JText::_('COM_BT_PROPERTY_LOCATION');?></label>
<?php echo $this->form->getInput('country'); ?>
</div>
<div class="form-group">
<?php echo $this->form->getInput('city'); ?>
</div>
Thank you for your time. Any suggestion is much appreciated!

How to pass php variable to modal window

I am making a simple page and I have found this little problem. I have this in my template:
<?php foreach ($this->vypis_serie as $value) : ?>
<div class="serie">
<div id="serie_header">
<?= $value['nazev_cviceni'] ?>
</div>
<div id="serie_info">
<p>Number of excercises: TODO</p>
<p>Sport type: <?= $value['typ'] ?></p>
<p>KCal summary: <?= $value['kcal'] ?></p>
</div>
<div class="button_upravit">Edit</div>
<div class="button_smazat">Delete</div>
</div>
<?php endforeach; ?>
basically it is a block that fills in information about particular exercise (it is a sport app). SO If I have 3 entries in DB, it will print this code three times with corresponding info.
The problem I have is with the edit button, which upon clicking opens modal window. It is made purely with CSS, so no Javascript.
When I click the button, it jumps to this code:
<div id="openModal_edit" class="modalDialog">
<div>
X
<div id="editace">
<form id="platba" action="serie/edit/" method="post" enctype="multipart/form-data">
<fieldset>
<legend>Edit serie</legend>
<ol>
<li>
<label for="name">Name of the series</label>
<input id="name" name="nazev_cviceni" type="text" required autofocus>
</li>
<li>
<label for="typ">Sport type</label>
<select name="typ">
<option value="Kolo">Bike</option>
<option value="Bฤ›hรกnรญ" selected="selected">Running</option>
</select>
</li>
</ol>
</fieldset>
<fieldset>
<button type="submit">Save</button>
</fieldset>
</form>
</div>
</div>
</div>
But since I jump to div id and I am not using a new page where I could choose a controller and pass a variable, I need somehow to pass the variable (id of the exercise) to the modal window, so I can know which of the possible buttons I have clicked. Is there any way to do it, without the need to rewrite all other pages where I have used this modal window?
I can't use another foreach like in the first part, because the modal window is always a single object that appears, unlike all the entries on the page that are there as many times as there are entries in the DB.
Hope that it is understandable, sorry for my English :)
The simplest way to do this using a single modal window involves adding some javascript code to your page.
First, add the relevant information to the edit link, with a new data-serie-<name> for each piece of data you want to pass:
<a href="#openModal_edit" data-serie-name="<?= $value['nazev_cviceni'] ?>" ...>
Next, add an onclick event handler to that same link. This handler will extract the embedded data from the <a> element and inject it in the modal window. The dataset element provides access to the data-* attributes from javascript
// Example
onclick="serieName=this.dataset.serieName;document.querySelector('#openModal_edit input#name').value = serieName;return true;"

show the item to edit on dropdown

I am using the same view page for both submitting data to database and editing. When I submit the form all the elements go to database. When editing the input field contains the item to edit but the dropdown form doesnot load and displays error saying $expensetype not defined. the $expensetype is passed through the controller to the form. I am developing in pyrocms. Pyrocms is developed in Codeigniter.
<li>
<label for="expense_type_id">Expense Type</label> <!-- expense_type_id-->
<div class="input">
<?php echo form_dropdown("expense_type_id",$expensetype, set_value("expense_type_id", $expense_type_id)); ?>
</div>
</li><li>
<label for="expense_rs">Expense(NRS)</label> <!-- expense_rs-->
<div class="input">
<?php echo form_input("expense_rs", set_value("expense_rs", $expense_rs)); ?>
</div>
</li>
How to make the dropdown to show the item while editing.

How to add a textfield in form with out model class in YII?

I need to add a text field in YII form in which i am not specify any model class name. But I need to process that value in the action method inside the controller class.
ie
I need to add a text field as
<div class="row">
<input type="text" name="test" id="test" >
</div>
I add text field as
<?php echo $form->textField($model['groupModel'],'group_name',array('size'=>60,'maxlength'=>128)); ?>
But i do't want to specify any model name with the new text field..
Thanks in advance...
This should work
<div class="row">
<?php echo CHtml::textField('User[textvalue]', '', array('size'=>60,'maxlength'=>128)); ?>
</div>
This will give you the text value inside $_POST['User'] as $_POST['User']['textvalue']
You can add a Chtml textfield with an id
It will the show in the: $_POST['mytextField']

Categories