Welcome, Guest
Username: Password: Remember me

TOPIC: [SOLVED] Link from list view to other view?

Link from list view to other view? 14 Jun 2015 07:35 #13260

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
I want to create button links on a list view to a different view in the component. The first button would open a modal view of a new action for the item selected. It would take the id of the entry and fill a field called [incidentid] in the action item view = the id of the item selected from the list.. If that makes sense?

The second button would open a new window of the action items " list view" filtered by the item selected. Each item relating to the item selected would have the same incidentid.

The list view would look like the image below. I have added fake images to show what I am looking for..



If I could code it i would. But old dogs just don't learn new tricks easily these days.
The administrator has disabled public write access.

Link from list view to other view? 14 Jun 2015 09:27 #13261

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
For your case you just need to deal with urls and modals.

- For calling a task and return result in modal it is not possible with a POST statement, so you can just use a GET param in the url . (&task=add)

- For filtering a list, you need this list to have a filter created in the builder (for the same client side context - back or front). And then add in the URL &filter_myfilter=myvalue

- For Modal : in JDom call, just add 'target' => 'modal'
- For the button style, I think you can just add 'btn' in the class. in JDom : 'domClass' => 'btn'


Hope it helps.
If you need more details, just ask.

PS : By the way : Good image host with popup is nice.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: jonathanbell

Link from list view to other view? 15 Jun 2015 10:04 #13265

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
Thanks. I gave it a go but to be honest I'm lost.

The link does not necesarily have to be a button, and it does not necessarily need to open a modal - could simply be a new page _blank. I have looked up the Get statement and all the pages visited so far show you how to get the information from the link but not how to put the information in the link from the current form.. e.g I would like it to add ' ?incidentid= [what ever the code is to show the ID of the line the button was clicked on'

I would then Get the information and update the new form field 'Incident' .. " I think ,, based on what I have read up on so far" :blush:

Below is what I have added to the end of the array. " It currently shows nothing"
<?php echo JDom::_('html.fly', array(
						'value'=>'Add item',
						'route' => array('view' => 'actionsitem','layout' => 'actionsitem','cid[]' => $row->id),
						'target' => '_blank',
						'viewType' => 'btn'
					));?>		
</tr>

If I change the ?php echo JDom::_('html.fly.btn' ..... the page gives an error "cannot find JDOM btn"
If I change it to html.fly.bool it will show a yes no button of sorts but the button does nothing.

So I suppose here are the questions-

- Whats up with the code - " if I wanted it to be a button"?
- Can I add to the end of the route - IncidentId=> $row->id) so that it can be picked up when the other page opens.
- Would changing the cid to 0 make the page open as a new entry?

Sorry my PHP understanding is very very basic
The administrator has disabled public write access.

Link from list view to other view? 16 Jun 2015 09:27 #13270

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
Ok. I've got the link to pass the field data I want to the URL. I've gone away from trying to use button, as the link was not working. I added two additional fields to the incident reporting table. One called add action and one called view actions. Below I am testing if the code works to create the url and then open a page. It does. One opens the action item as a modal, one as a new page. Just for practice.
</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly', array(
						'dataKey' => 'add_actions',
						'dataObject' => $row,
						'route' => array('view' => 'actionsitem','layout' => 'actionsitem','incidentid' => $row->id),
						'target' => 'modal'
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly', array(
						'dataKey' => 'view_actions',
						'dataObject' => $row,
						'route' => array('view' => 'actionsitem','layout' => 'actionsitem','incidentid' => $row->id),
						'target' => '_blank'
					));?>
				</td>

Now I don't quite understand where I put the Get statement or what exactly it should look like on the action items page.

Here is the current code for the Action Item..
<?php
/**                               ______________________________________________
*                          o O   |                                              |
*                 (((((  o      <    Generated with Cook Self Service  V2.7     |
*                ( o o )         |______________________________________________|
* --------oOOO-----(_)-----OOOo---------------------------------- www.j-cook.pro --- +
* @version		1.02
* @package		Safety 101
* @subpackage	Incident Actions
* @copyright	2014 Jonathan Bell
* @author		Jonathan Bell - www.saferecord.org - contact@mmb.co.nz
* @license		Commercial
*
*             .oooO  Oooo.
*             (   )  (   )
* -------------\ (----) /----------------------------------------------------------- +
*               \_)  (_/
*/

// no direct access
defined('_JEXEC') or die('Restricted access');


if (!$this->form)
	return;

$fieldSets = $this->form->getFieldsets();
?>
<?php $fieldSet = $this->form->getFieldset('actionsitem.form');?>
<fieldset class="fieldsform form-horizontal">


	<?php
	// Person responsible
	$field = $fieldSet['jform_person_responsible'];
	$field->jdomOptions = array(
		'list' => $this->lists['fk']['person_responsible']
			);
	?>
	<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
		<div class="control-label">
			<?php echo $field->label; ?>
		</div>
	
	    <div class="controls">
			<?php echo $field->input; ?>
		</div>
	</div>



	<?php
	// Date due
	$field = $fieldSet['jform_action_due_date'];
	?>
	<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
		<div class="control-label">
			<?php echo $field->label; ?>
		</div>
	
	    <div class="controls">
			<?php echo $field->input; ?>
		</div>
	</div>



	<?php
	// Short description
	$field = $fieldSet['jform_action_title'];
	?>
	<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
		<div class="control-label">
			<?php echo $field->label; ?>
		</div>
	
	    <div class="controls">
			<?php echo $field->input; ?>
		</div>
	</div>



	<?php
	// Full description
	$field = $fieldSet['jform_full_description'];
	?>
	<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
		<div class="control-label">
			<?php echo $field->label; ?>
		</div>
	
	    <div class="controls">
			<?php echo $field->input; ?>
		</div>
	</div>



	<?php
	// Completed date
	$field = $fieldSet['jform_action_completed_date'];
	?>
	<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
		<div class="control-label">
			<?php echo $field->label; ?>
		</div>
	
	    <div class="controls">
			<?php echo $field->input; ?>
		</div>
	</div>



	<?php
	// Action completed
	$field = $fieldSet['jform_completed_yn'];
	?>
	<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
		<div class="control-label">
			<?php echo $field->label; ?>
		</div>
	
	    <div class="controls">
			<?php echo $field->input; ?>
		</div>
	</div>



	<?php
	// Incident
	$field = $fieldSet['jform_incident'];
	?>
	<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
		<div class="control-label">
			<?php echo $field->label; ?>
		</div>
	
	    <div class="controls">
			<?php echo $field->input; ?>
		</div>
	</div>
</fieldset>

I think I need to use

$incidentid=Get[$incidentid] ;

But it comes up with unexpected T variable??? Which is the start of my problem. How do I get the variable incidentid from the url variable into the incident field, now I have the process of creating the URL correct?

I'm a slow learner but getting there.
The administrator has disabled public write access.

Link from list view to other view? 20 Jun 2015 10:36 #13285

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
And here is the final code that now points to the right forms and opens them . The filter works.
<?php
/**                               ______________________________________________
*                          o O   |                                              |
*                 (((((  o      <    Generated with Cook Self Service  V2.7     |
*                ( o o )         |______________________________________________|
* --------oOOO-----(_)-----OOOo---------------------------------- www.j-cook.pro --- +
* @version		1.02
* @package		Safety 101
* @subpackage	Incident Entry
* @copyright	2014 Jonathan Bell
* @author		Jonathan Bell - www.saferecord.org - contact@mmb.co.nz
* @license		Commercial
*
*             .oooO  Oooo.
*             (   )  (   )
* -------------\ (----) /----------------------------------------------------------- +
*               \_)  (_/
*/

// no direct access
defined('_JEXEC') or die('Restricted access');


JHtml::addIncludePath(JPATH_ADMIN_SAFETY101.'/helpers/html');
JHtml::_('behavior.tooltip');
//JHtml::_('behavior.multiselect');

$model		= $this->model;
$user		= JFactory::getUser();
$userId		= $user->get('id');
$listOrder	= $this->escape($this->state->get('list.ordering'));
$listDirn	= $this->escape($this->state->get('list.direction'));
$saveOrder	= $listOrder == 'a.ordering' && $listDirn != 'desc';
?>
<div class="clearfix"></div>
<div class="">
	<table class='table' id='grid-incidententry'>
		<thead>
			<tr>
				<?php if ($model->canSelect()): ?>
				<th>
					<?php echo JDom::_('html.form.input.checkbox', array(
						'dataKey' => 'checkall-toggle',
						'title' => JText::_('JGLOBAL_CHECK_ALL'),
						'selectors' => array(
							'onclick' => 'Joomla.checkAll(this);'
						)
					)); ?>
				</th>
				<?php endif; ?>

				<th>

				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_CREATION_DATE"); ?>
				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_ID"); ?>
				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_REPORTED_BY"); ?>
				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_INCIDENT_DATE"); ?>
				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_SITE"); ?>
				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_DEPARTMENT"); ?>
				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_EMPLOYEE_INVOLVED"); ?>
				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_SHORT_DESCRIPTION"); ?>
				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_STATUS"); ?>
				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_ACTIONS_COMPLETED_1"); ?>
				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_ADD_ACTIONS"); ?>
				</th>

				<th style="text-align:center">
					<?php echo JText::_("SAFETY101_FIELD_VIEW_ACTIONS"); ?>
				</th>
			</tr>
		</thead>
		<tbody>
		<?php
		$k = 0;
		for ($i=0, $n=count( $this->items ); $i < $n; $i++):
			$row = $this->items[$i];
			?>

			<tr class="<?php echo "row$k"; ?>">
				<?php if ($model->canSelect()): ?>
				<td>
					<?php if ($row->params->get('access-edit') || $row->params->get('tag-checkedout')): ?>
						<?php echo JDom::_('html.grid.checkedout', array(
													'dataObject' => $row,
													'num' => $i
														));
						?>
					<?php endif; ?>
				</td>
				<?php endif; ?>

				<td>
					<div class="btn-group">
						<?php if ($model->canEdit()): ?>
							<?php if ($row->params->get('access-edit')): ?>
								<?php echo JDom::_('html.grid.task', array(
									'commandAcl' => array('core.edit.own', 'core.edit'),
									'label' => 'SAFETY101_JTOOLBAR_EDIT',
									'num' => $i,
									'task' => 'incidentitem.edit'
								));?>
							<?php endif; ?>
						<?php endif; ?>
					</div>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly.datetime', array(
						'dataKey' => 'creation_date',
						'dataObject' => $row,
						'dateFormat' => 'd-m-Y H:i:s'
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly', array(
						'dataKey' => 'id',
						'dataObject' => $row
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly', array(
						'dataKey' => '_person_reporting_name',
						'dataObject' => $row
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly.datetime', array(
						'dataKey' => 'incident_date',
						'dataObject' => $row,
						'dateFormat' => 'd.m.Y'
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly', array(
						'dataKey' => '_site_site',
						'dataObject' => $row
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly', array(
						'dataKey' => '_department_department',
						'dataObject' => $row
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly', array(
						'dataKey' => '_employee_involved_name',
						'dataObject' => $row
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly', array(
						'dataKey' => 'short_description',
						'dataObject' => $row
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly.enum', array(
						'dataKey' => 'status',
						'dataObject' => $row,
						'labelKey' => 'text',
						'list' => Safety101Helper::enumList('incidententry', 'status'),
						'listKey' => 'value'
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly.bool', array(
						'dataKey' => 'actions_completed',
						'dataObject' => $row,
						'route' => array('view' => 'actionsitem','layout' => 'actionsitem','cid[]' => $row->id),
						'target' => '_blank',
						'togglable' => false,
						'viewType' => 'icon'
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly', array(
						'dataKey' => 'add_actions',
						'dataObject' => $row,
						'route' => array('view' => 'actionsitem','layout' => 'actionsitem','entered' => $row->creation_date),
						'target' => '_blank'
					));?>
				</td>

				<td style="text-align:center">
					<?php echo JDom::_('html.fly', array(
						'dataKey' => 'view_actions',
						'dataObject' => $row,
						'route' => array('view' => 'incidentactions','&filter_incident' => $row->creation_date),
						'target' => 'modal'
					));?>
				</td>
			</tr>
			<?php
			$k = 1 - $k;
		endfor;
		?>
		</tbody>
	</table>
</div>

The changes are simply

'route' => array('view' => 'actionsitem','layout' => 'actionsitem','entered' => $row->creation_date),

'route' => array('view' => 'incidentactions','&filter_incident' => $row->creation_date),

- So anyone up to helping with adding this value to the incident field on the incident actions form?
The administrator has disabled public write access.

Link from list view to other view? 20 Jun 2015 13:45 #13287

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Did you got it fixed ?

I do not get your point.

Can you try to sumplify the code and share only the strict necessary, please ?
Also, I can see you have still a '&' before 'filter_incident' in the route array and this is not necessary

Remove the '&'
'route' => array('view' => 'incidentactions','&filter_incident' => $row->creation_date),
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: jonathanbell

Link from list view to other view? 21 Jun 2015 05:25 #13288

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
Hi thanks Chef , I have it all sorted. Happy to post my whole example if you want. I will remove the & even though it seems to work fine.
My problem is I am a beginner coder so sometimes explaining what I want may go off course.
Last Edit: 21 Jun 2015 05:25 by jonathanbell. Reason: spelling
The administrator has disabled public write access.
Time to create page: 0.088 seconds

Get Started