Welcome, Guest
Username: Password: Remember me

TOPIC: Forking layouts, calling original from forked

Forking layouts, calling original from forked 05 Jul 2013 17:48 #7885

  • jhallock
  • jhallock's Avatar
  • Offline
  • Senior Member
  • Posts: 43
  • Thank you received: 1
  • Karma: 0
I am forking a layout for a view. Is is possible to call the original file from within the forked file. So for example I have:
./views/employees/default.php

and
./fork/views/employees/default.php

Inside ./fork/views/employees/default.php I want to load ./views/employees/default.php, and then add some other stuff it before echoing it out to be displayed.

Thanks.
The administrator has disabled public write access.

Forking layouts, calling original from forked 06 Jul 2013 08:05 #7893

  • BTB300
  • BTB300's Avatar
  • Online
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
Copy your original default.php to the fork file (its just a mirror of the original directory)
copy your default.php from the
views/tmpl directory 
to
 fork/views/tmpl directory 
(if the tmpl directory is not there create it)
look for the call to your template in your default.php
		<div>

			<!-- BRICK : grid -->
			<?php echo $this->loadTemplate('grid'); ?>
		</div>

if you want to call another view as well as and the original copy it to to the tmpl directory in the fork

in the fork directory lets say i have 3 templates
myview.php
myview_grid_header.php
myview_grid.php
myview_grid_footer.php

editing your default.php in the fork tmpl directory like this will load all three views from the fork directory
		<div>

			<!-- BRICK : grid_header -->
			<?php echo $this->loadTemplate('grid_header'); ?>
          
                       <!-- BRICK : grid -->
			<?php echo $this->loadTemplate('grid'); // your original view ?>

                      <!-- BRICK : grid_footer-->
			<?php echo $this->loadTemplate('grid_footer'); ?>

		</div>

Got it now?

BTW if you want to see the changes in your original myview_grid.php
dont copy it to the fork directory and it will load your original from the views/tmpl directory

so your fork directory would look like this
myview.php
myview_grid_header.php
myview_grid_footer.php

And your views/tmpl looks like this
myview.php <- changes to this file are not loaded as there is a file with the same name in the fork
myview_grid is loaded from the original <- changes to this file are reflected in the output because there is not a copy in the fork
Last Edit: 06 Jul 2013 08:28 by BTB300.
The administrator has disabled public write access.
The following user(s) said Thank You: admin

Forking layouts, calling original from forked 07 Jul 2013 12:20 #7901

  • etc
  • etc's Avatar
  • Offline
  • Premium Member
  • Posts: 132
  • Thank you received: 19
  • Karma: 7
Is it possible to put files from images and css folder to fork directory as well?
The administrator has disabled public write access.

Forking layouts, calling original from forked 07 Jul 2013 12:55 #7903

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Yes.

Css are loaded AFTER your component css, so you can override it.
From the CSS you lad the forked images. (../images/xxxxxx.png)
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: etc

Forking layouts, calling original from forked 08 Jul 2013 16:36 #7913

  • jhallock
  • jhallock's Avatar
  • Offline
  • Senior Member
  • Posts: 43
  • Thank you received: 1
  • Karma: 0
I understand how to move files to the fork directory.

Specifically though, I want to be able to call my original default.php from inside the forked default.php You didn't really say whether or not that is possible.

In this way, any updates I make to the original by using j-cook will still be be displayed without me having to update the forked default.php.

Is this specific ability possible? If not, It would be great to have a function to do that.

Thank you.
The administrator has disabled public write access.

Forking layouts, calling original from forked 10 Jul 2013 20:47 #7930

  • BTB300
  • BTB300's Avatar
  • Online
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
BTB300 wrote:

BTW if you want to see the changes in your original myview_grid.php
dont copy it to the fork directory and it will load your original from the views/tmpl directory

so your fork directory would look like this
myview.php
myview_grid_header.php
myview_grid_footer.php

And your views/tmpl looks like this
myview.php <- changes to this file are not loaded as there is a file with the same name in the fork
myview_grid is loaded from the original <- changes to this file are reflected in the output because there is not a copy in the fork

myview.php calls the other templates
put myview.php in your fork file and it will call your updated template from the standard directory
when you overwrite your component (install over the top) the fork file is left untouched

sorry i didnt explain it better last time
The administrator has disabled public write access.

Forking layouts, calling original from forked 11 Jul 2013 17:47 #7934

  • jhallock
  • jhallock's Avatar
  • Offline
  • Senior Member
  • Posts: 43
  • Thank you received: 1
  • Karma: 0
I understood your explanation fine. I don't think you are grasping what it is I want to do.

I have /fork/views/employees/tmpl/default.php

I want to include the content from /views/employees/tmpl/default.php FROM INSIDE /fork/views/employees/tmpl/default.php.

I want to do this without copying and pasting the content from the original into the forked. In this way, changes to the original will propagate to my component without me having to copy and paste every time I update.

This has nothing to do with the default_grid.php or default_filters.php

I think what you are telling me is that it's not possible...

Here is an example:

/views/employees/tmpl/default.php contains the following:
<?php
defined('_JEXEC') or die('Restricted access');
ChronosHelper::headerDeclarations();
?>

<h2><?php echo $this->title;?></h2>
<form action="<?php echo(JRoute::_("index.php")); ?>" method="post" name="adminForm" id="adminForm">
	<div>
		<div>

			<!-- BRICK : toolbar_plur -->
			<?php echo JDom::_('html.toolbar', array(
				"bar" => JToolBar::getInstance('toolbar')
			));?>
		</div>
		<div>

			<!-- BRICK : filters -->
			<div class="pull-left">
				<?php if ($this->canDo->get('core.edit.state')): ?>
					<?php echo $this->filters['filter_published']->input;?>
				<?php endif; ?>

			</div>
			<div class="pull-left">
				<?php echo $this->filters['filter_facility']->input;?>
			</div>
			<div class="pull-left">
				<?php echo $this->filters['filter_position']->input;?>
			</div>
			<div class="pull-right">
				<?php echo $this->filters['limit']->input;?>
			</div>
			<div class="pull-right">
				<?php echo $this->filters['directionTable']->input;?>
			</div>
			<div class="pull-right">
				<?php echo $this->filters['sortTable']->input;?>
			</div>
			<div class="clearfix"></div>
			<div class="pull-right">
				<?php echo $this->filters['search_search_name']->input;?>
			</div>

		</div>
		<div>

			<!-- BRICK : grid -->
			<?php echo $this->loadTemplate('grid'); ?>
		</div>
		<div>

			<!-- BRICK : pagination -->
			<?php echo $this->pagination->getListFooter(); ?>
		</div>
	</div>


	<?php 
		$jinput = JFactory::getApplication()->input;
		echo JDom::_('html.form.footer', array(
		'values' => array(
					'view' => $jinput->get('view', 'employees'),
					'layout' => $jinput->get('layout', 'default'),
					'boxchecked' => '0',
					'filter_order' => $this->escape($this->state->get('list.ordering')),
					'filter_order_Dir' => $this->escape($this->state->get('list.direction'))
				)));
	?>
</form>


/fork/views/employees/tmpl/default.php would contain this:
<?php
defined('_JEXEC') or die('Restricted access');
?>
.. some function call to include the original default.php for example ...
<?php echo $this->loadOriginalTemplate('default'); ?>

<div>This div will display AFTER the original default.php content. Any changes to the original default.php will be displayed on this page. I can update the original , and the changes will be displayed, along with this additional content.</div>

The administrator has disabled public write access.

Forking layouts, calling original from forked 11 Jul 2013 22:14 #7936

  • jhallock
  • jhallock's Avatar
  • Offline
  • Senior Member
  • Posts: 43
  • Thank you received: 1
  • Karma: 0
To further clarify what I am asking, you gave this response:
And your views/tmpl looks like this
myview.php <- changes to this file are not loaded as there is a file with the same name in the fork
myview_grid is loaded from the original <- changes to this file are reflected in the output because there is not a copy in the fork

What I want:
And your views/tmpl looks like this
myview.php <- changes to this file are loaded because I told the forked file to load this file
myview_grid is loaded from the original <- changes to this file are reflected in the output because there is not a copy in the fork

I'm going to go ahead and assume this isn't possible as it stands (correct me if I am wrong). It would be a great feature for the next release.
The administrator has disabled public write access.

Forking layouts, calling original from forked 12 Jul 2013 05:46 #7938

  • etc
  • etc's Avatar
  • Offline
  • Premium Member
  • Posts: 132
  • Thank you received: 19
  • Karma: 7
Hi,

it seems to me you are trying to use fork in different way than it was designed
The administrator has disabled public write access.
The following user(s) said Thank You: jhallock
Time to create page: 0.108 seconds

Get Started