custom linked view in admin #151

Closed
opened 2017-10-26 13:07:36 +00:00 by sepehr09 · 9 comments
sepehr09 commented 2017-10-26 13:07:36 +00:00 (Migrated from github.com)

hi, i want to customize linked view in my component because some field like date need to be changed. but changing that in model (Add PHP (getItems Method - after all)) does not affect in linked view!
how we can customize linked view like this picture ?
image

hi, i want to customize linked view in my component because some field like date need to be changed. but changing that in model (Add PHP (getItems Method - after all)) does not affect in linked view! how we can customize linked view like this picture ? ![image](https://user-images.githubusercontent.com/11753906/32054556-9c0c6a74-ba6b-11e7-9f62-2b6db9deda54.png)

Please watch this tutorial as it explains how to prevent list view items from being escaped.

Here is a little code snipped I used to achieve the same

if ([[[Component]]]Helper::checkArray($items))
{
	if (!isset($_export) || !$_export)
	{
		// time switches
		$danger = JFactory::getDate()->modify(JComponentHelper::getParams('com_jobtracking')->get('danger_time', '-3 week'))->toUnix();
		$warning = JFactory::getDate()->modify(JComponentHelper::getParams('com_jobtracking')->get('warning_time', '-1 week'))->toUnix();
	}
	foreach ($items as $nr => &$item)
	{
		// insure job Number is always unique
		[[[Component]]]Helper::uniqueNr($item, 'job_order.jobnumber');
		if (!isset($_export) || !$_export)
		{
			// check if there is a problem on the products needed
			if ([[[Component]]]Helper::hasProblem($item->id))
			{
				// has a problem
				$item->job_status =  '<span class="vdm-text-danger">' . $item->job_status . '</span>';
			}
			// set the timers
			if (isset($item->created) && $item->created != '0000-00-00 00:00:00' && !empty($item->created))
			{
				$item->created = strtotime($item->created);
				// check date
				if ($item->created < $danger)
				{
					// set danger
					$item->created = '<span class="vdm-badge vdm-danger">' . [[[Component]]]Helper::fancyDate($item->created) . '</span>';
				}
				elseif ($item->created < $warning)
				{
					// set warning
					$item->created = '<span class="vdm-badge vdm-warning">' . [[[Component]]]Helper::fancyDate($item->created) . '</span>';
				}
				else
				{
					// set okay
					$item->created = '<span class="vdm-badge vdm-success">' . [[[Component]]]Helper::fancyDate($item->created) . '</span>';
				}
			}
			else
			{
				$item->created = '';
			}
			if (isset($item->delivery_date) && $item->delivery_date != '0000-00-00 00:00:00' && !empty($item->delivery_date))
			{
				$item->delivery_date = [[[Component]]]Helper::fancyDate(strtotime($item->delivery_date));
			}
			else
			{
				$item->delivery_date = '';
			}
		}
	}
}

O yes and I added this to Add PHP (getItems Method - before translation fix & decryption) since I wanted to be sure I use the raw untouched values.

Please watch [this tutorial](https://youtu.be/bfl0l3AoLKU?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE) as it explains how to prevent list view items from being escaped. Here is a little code snipped I used to achieve the same ``` if ([[[Component]]]Helper::checkArray($items)) { if (!isset($_export) || !$_export) { // time switches $danger = JFactory::getDate()->modify(JComponentHelper::getParams('com_jobtracking')->get('danger_time', '-3 week'))->toUnix(); $warning = JFactory::getDate()->modify(JComponentHelper::getParams('com_jobtracking')->get('warning_time', '-1 week'))->toUnix(); } foreach ($items as $nr => &$item) { // insure job Number is always unique [[[Component]]]Helper::uniqueNr($item, 'job_order.jobnumber'); if (!isset($_export) || !$_export) { // check if there is a problem on the products needed if ([[[Component]]]Helper::hasProblem($item->id)) { // has a problem $item->job_status = '<span class="vdm-text-danger">' . $item->job_status . '</span>'; } // set the timers if (isset($item->created) && $item->created != '0000-00-00 00:00:00' && !empty($item->created)) { $item->created = strtotime($item->created); // check date if ($item->created < $danger) { // set danger $item->created = '<span class="vdm-badge vdm-danger">' . [[[Component]]]Helper::fancyDate($item->created) . '</span>'; } elseif ($item->created < $warning) { // set warning $item->created = '<span class="vdm-badge vdm-warning">' . [[[Component]]]Helper::fancyDate($item->created) . '</span>'; } else { // set okay $item->created = '<span class="vdm-badge vdm-success">' . [[[Component]]]Helper::fancyDate($item->created) . '</span>'; } } else { $item->created = ''; } if (isset($item->delivery_date) && $item->delivery_date != '0000-00-00 00:00:00' && !empty($item->delivery_date)) { $item->delivery_date = [[[Component]]]Helper::fancyDate(strtotime($item->delivery_date)); } else { $item->delivery_date = ''; } } } } ``` O yes and I added this to **Add PHP (getItems Method - before translation fix & decryption)** since I wanted to be sure I use the raw untouched values.

The linked view is really a mirror of the actual admin view. So making any changes to the admin view should reflect where that admin view is linked.

I have not tested this extensively, but here is the result of the above code in a linked view with FooTable V3

image

The linked view is really a mirror of the actual admin view. So making any changes to the admin view should reflect where that admin view is linked. I have not tested this extensively, but here is the result of the above code in a linked view with FooTable V3 ![image](https://user-images.githubusercontent.com/5607939/32055211-689eb426-ba61-11e7-9b19-be215f07594c.png)
sepehr09 commented 2017-10-26 13:55:17 +00:00 (Migrated from github.com)

that is work in list view but not working in linked view !
i dont know why.
image
image
image

that is work in list view but not working in linked view ! i dont know why. ![image](https://user-images.githubusercontent.com/11753906/32056675-292111de-ba72-11e7-8595-8a70c2fe53e2.png) ![image](https://user-images.githubusercontent.com/11753906/32056694-3a75bf8e-ba72-11e7-8967-3c690c334ba1.png) ![image](https://user-images.githubusercontent.com/11753906/32056848-8ef6b3ec-ba72-11e7-9a6a-17fc3727d198.png)
sepehr09 commented 2017-10-26 14:08:37 +00:00 (Migrated from github.com)

even if i delete administrator/components/com_mycomponent/models/someview_list.php the linked view in tab still working! just admin view broke !

even if i delete `administrator/components/com_mycomponent/models/someview_list.php` the linked view in tab still working! just admin view broke !

It does not call the same model, it builds that same functions (class methods) into the model where it is linked. So can you look in the Sale model and share the method you find there?

It does not call the same model, it builds that same functions (class methods) into the model where it is linked. So can you look in the **Sale** model and share the method you find there?

I also notice that these are not the same linked views... the one has description and the other does not, so please check that you are linking to the correct view.

I also notice that these are not the same linked views... the one has description and the other does not, so please check that you are linking to the correct view.

System Name is what helps to identify views that have the same names, but are used in different components. Well that is what I use system name for 👍

System Name is what helps to identify views that have the same names, but are used in different components. Well that is what I use system name for :+1:
sepehr09 commented 2017-10-26 14:34:53 +00:00 (Migrated from github.com)

yes ! the model for linked view is inside parent model! the model for crm tab is inside the sale model ! the problem solved!
i have another question how can i change linked view design? like sermondistributor (dark blue) .
i haven't any site view or dynamics get.
thank you

yes ! the model for linked view is inside parent model! the model for `crm` tab is inside the `sale` model ! the problem solved! i have another question how can i change linked view design? like sermondistributor (dark blue) . i haven't any site view or dynamics get. thank you

Hey JCB is not yet that smart... but hey with guys like you around I am sure we will get there. For now you can only add css to the page and target the table classes. But we could in the future look at this.

If you have a plan on how and what... then open an issue as a feature request and we will bump it into the feature request project here on github.

Hey JCB is not yet that smart... but hey with guys like you around I am sure we will get there. For now you can only add css to the page and target the table classes. But we could in the future look at this. If you have a plan on how and what... then open an issue as a feature request and we will bump it into the feature [request project here on github](https://github.com/vdm-io/Joomla-Component-Builder/projects/5).
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#151
No description provided.