Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] Fork function not working ?

Fork function not working ? 28 Feb 2015 13:33 #12855

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
Would it be possible that the fork function doens't work at this moment ?
I tried to add some lines to the public function save ($data) as i often do, i placed it in the _fork/model/the_file.php and nothing happens.
Can somebody confirm this please ?
Thanks,
V.
The administrator has disabled public write access.

Fork function not working ? 28 Feb 2015 14:36 #12856

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

Simple :
_fork is not the directory !
It only contains the empty files fork templates.

From this directory, move the file you want to the 'fork' directory.
That's it.

www.j-cook.pro/index.php/f/forks
Coding is now a piece of cake
The administrator has disabled public write access.

Fork function not working ? 28 Feb 2015 14:44 #12857

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
Hi VeCrea
your directory _fork/.....
for me i had to create the fork directory without the underscore
\helpers\helper.php
public static function loadFork($file)
	{
		//Transform the file path to reach the fork directory
		$file = preg_replace("#com_mycomponent#", 'com_mycomponent' .DS. 'fork', $file);
		// Load the fork file.
		if (!empty($file) && file_exists($file))
			include_once($file);
	}

further to this
i wonder from another post in the display function in view.html.php
$this->addForkTemplatePath()
it calls this function below in the file

administrator/components/com_mycomponent/classes/view/view.php
protected function addForkTemplatePath()
	{
		$this->addTemplatePath(JPATH_COMPONENT .DS. 'fork' .DS. 'views' .DS. $this->getName() .DS. 'tmpl');
	}


question is why on the administrator side does it add TemplatePath containing JPATH_COMPONENT should this not be JPATH_COMPONENT_ADMINISTRATOR
from the Joomla documentation
JPATH_COMPONENT	The path to the current component being executed.
JPATH_COMPONENT_ADMINISTRATOR	The path to the administration folder of the current component being executed.


have a look inside the above function
$this->addTemplatePath(JPATH_COMPONENT .DS. 'fork' .DS. 'views' .DS. $this->getName() .DS. 'tmpl');
and where does this function reside?? i am guessing in CkJView but where is the CkJView class (guessing the plugin)
(again should it not call the component admin path?)

Just a quick look but there could be a valid reason why admin side is calling JPATH_COMPONENT rather than JPATH_COMPONENT_ADMINISTRATOR
The administrator has disabled public write access.

Fork function not working ? 28 Feb 2015 14:55 #12860

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
JPATH_COMPONENT return the backend path when it is executed from admin. Otherwhise it returns front-end path.

JPATH_COMPONENT_ADMINISTRATOR = back-end component root
JPATH_COMPONENT_SITE = front-end component root

See : docs.joomla.org/Constants
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: BTB300

Fork function not working ? 28 Feb 2015 15:16 #12862

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
Thanks Admin
Was unaware that the that JPATH_COMPONENT returned admin side when executed from admin... Learn something every day

I also note that at the bottom of the Joomla Constants document that I thought I might raise here for future reference seeing we are discussing constants in this thread especially for those of us that split or components and make use of the fork files to display data from other components
Whilst using JPATH_COMPONENT and JPATH_COMPONENT_ADMINISTRATOR is highly useful in some cases, it has one big disadvantage: it immediately breaks all attempts to reuse the model from another component. That's something to keep in mind.
may just help someone trouble shooting one day....
Last Edit: 28 Feb 2015 15:18 by BTB300.
The administrator has disabled public write access.
The following user(s) said Thank You: admin

Fork function not working ? 28 Feb 2015 15:37 #12866

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
This is excellent remark.

This is why I normaly avoid them in cook, redeclaring new constants specific to component.
But, you are right then the forks cannot work properly because I use the common constant in this function.

Excellent catch man. I love it. Improvements every day.
I will improve it as soon as I can, it is easy to fix.
Coding is now a piece of cake
The administrator has disabled public write access.

Fork function not working ? 16 Mar 2016 12:16 #13849

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Finaly FIXED.

I created a new constant var named JPATH_[MYCOMPONENT]
It will take respectlively from its client side, such as JPATH_COMPONENT, but it can be used outside of your component. And it will work better in case of a module based on another page.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.095 seconds

Get Started