Welcome, Guest
Username: Password: Remember me

TOPIC: Forking... what I'm missing?

Forking... what I'm missing? 31 Jul 2014 01:41 #12559

  • Mud-H
  • Mud-H's Avatar
  • Offline
  • New Member
  • Posts: 13
  • Karma: 0
I'm trying to use the fork system but I can't get it to work...
I followed the tutorial: www.j-cook.pro/index.php/f/forks but my component don't seem to run the fork folder. I'm trying this on a Grid view and I'm trying to forke the view.html.php file

Here's the code I'm trying in the _fork view.html.php
class TestlabViewItems extends TestlabCkViewItems
{
	protected function displayDefault($tpl = null)
	{			
    	echo("Forked");  // Fork and replace the original function
  	}
		
	public function display($tpl = null)
	{
		 echo("Forked"); 
	}
}

I should only see "Forked" on my view if I understand right but it does nothing. Is there something I'm missing?
The administrator has disabled public write access.

Forking... what I'm missing? 31 Jul 2014 07:52 #12561

  • Mud-H
  • Mud-H's Avatar
  • Offline
  • New Member
  • Posts: 13
  • Karma: 0
I have investigate my issue and I suspect a small change I made for Joomla to work with Xampp to be the cause. It failed to load the forked file in the loadFork function:
public static function loadFork($file)
	{		
		//Transform the file path to reach the fork directory
		$file = preg_replace("#com_projectlab#", 'com_projectlab' .DS. 'fork', $file);		
		// Load the fork file.
		if (!empty($file) && file_exists($file)){
			include_once($file);
			echo("Loading Fork". $file);			
		}
	}
Loading fork never happen in that case.

EDIT: I'm sure I changed something to make the administrator page load on my setup but can't find it... I'm installing a fresh Joomla
Last Edit: 31 Jul 2014 08:00 by Mud-H. Reason: Can't find a xampp hack which might cause the issue
The administrator has disabled public write access.

Forking... what I'm missing? 31 Jul 2014 10:31 #12562

  • Mud-H
  • Mud-H's Avatar
  • Offline
  • New Member
  • Posts: 13
  • Karma: 0
:pinch: Well it was a stupid misunderstanding from my part... I should have read the fork documentation with more attention. The _fork folder need to be rename fork... Maybe it could be clearer in the documentation, there's no mention about it except the image on the side.

Well at least I have a clean new web server with fresh Joomla install :)

So should we only move the files that we fork in the fork folder or we can rename the _fork folder entirely?
The administrator has disabled public write access.

Forking... what I'm missing? 31 Jul 2014 10:42 #12563

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Hi Mud-H,

I am glad you got it sorted.
If you like, you can rename the whole folder _fork to fork, but it is not recommended.

First because it will load more files in memory, even when then are not used,
Secondly because this is really the goal of the fork feature : Storing in separated folder the changes. So the less files you have, the clearer it is because you see better where is your code and your changes.

When you go in production, you can merge the fork in their real places. If your component is a product you distribute, then it is much better and mor professional. If you instance your creations for specific dev clients, you can keep fork directory. It will also help further developpers.

In the case that you distribute your creations and so merge the forks in the original files, then it can be long job if you have copied all fork files. At least, if you copy only your changes, if will be faster.

Note: By the way, when you will merge the forks, be carefull with the keywords : parent , self
In facts, if you have used those keywords, check very well your code because your code will be affected.
Coding is now a piece of cake
The administrator has disabled public write access.

Forking... what I'm missing? 31 Jul 2014 14:20 #12564

  • Mud-H
  • Mud-H's Avatar
  • Offline
  • New Member
  • Posts: 13
  • Karma: 0
I'm still not sure if I understand well the self / parent keywords about the forking, I have still a lot to learn I guess. There's no hurry but I will make sure to investigate it better before using my component on a live website.
Also, about forking, if I understand it, there's no way to overide only a line in the middle, right? (can explain better what I mean so here's an example...)

I have added a addWhere before getting items of a model. For now, I have forked the entire function...
protected function displayAddissue($tpl = null)
	{
		$document	= JFactory::getDocument();
		$this->title = JText::_("PROJECTLAB_LAYOUT_ADD_ISSUE");
		$document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
              
             [...]		

		$model_issue_type = CkJModel::getInstance('Itemtypes', 'ProjectlabModel');
		$model_issue_type->addGroupOrder("a.name");
Added==>[b]$model_issue_type->addWhere ("a.table   LIKE '%issue%'");[/b]
		$lists['fk']['issue_type'] = $model_issue_type->getItems();

		$model_milestone_id = CkJModel::getInstance('Milestones', 'ProjectlabModel');
		$model_milestone_id->addGroupOrder("a.title");
		$lists['fk']['milestone_id'] = $model_milestone_id->getItems();
	}
Do the forking can help in this case? (In added a single line marked as Added==>)
The administrator has disabled public write access.

Forking... what I'm missing? 05 Aug 2014 12:57 #12570

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
This is correct.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.127 seconds

Get Started