I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem! Topic is solved

For Joomla! 4.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Post Reply
TruthSword
Joomla! Intern
Joomla! Intern
Posts: 70
Joined: Sat Feb 15, 2020 12:48 am

I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem!

Post by TruthSword » Sat Apr 30, 2022 11:09 pm

I'm working on doing ceford's Joomla 4x Component Tutorial (https://docs.joomla.org/J4_Component_example_-_Mywalks); and ran into a problem!

I copied the github file down and tar.gz'd and extracted in /joomla4/components/com_mywalks/ & set chown -R www:www com_mywalks and then went to Admin -> Discover and selected it; clicked install and it gave me an error (I couldn't preserve the error message; however it was an xml manifest error with something regarding cannot access or find /admin/*.sql ... aborting installation).

Since then; I checked permissions and I can't get Discover to find it again on Discovery. I even removed it; copied a new one in and re-ran Discover and it won't find it.

How do I remedy this?

Does anyone know?

Best Regards,

Brandon!

Thank you for this tutorial and website community for us Joomla Users!
Best Regards,

Mr. Brandon Kastning
Washington State, USA
Glory to Constitutional American Republic Forever! ;)
#SICSEMPERTYRANNIS

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2523
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem!

Post by SharkyKZ » Sun May 01, 2022 8:28 am

It' an installable package. You can install it normally using Extension Manager.
If for some reason you want to use Discover Install, you need to place files from admin directory and the mywalks.xml file in administrator/components/com_mywalks, and files from site directory in components/com_mywalks.

TruthSword
Joomla! Intern
Joomla! Intern
Posts: 70
Joined: Sat Feb 15, 2020 12:48 am

Re: I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem!

Post by TruthSword » Sun May 01, 2022 3:56 pm

SharkyKZ wrote:
Sun May 01, 2022 8:28 am
It' an installable package. You can install it normally using Extension Manager.
If for some reason you want to use Discover Install, you need to place files from admin directory and the mywalks.xml file in administrator/components/com_mywalks, and files from site directory in components/com_mywalks.
SharkyKZ,

Thank you! I will give this a try and hope it resolves! :)

Much appreciated!

Best Regards,

Brandon
Best Regards,

Mr. Brandon Kastning
Washington State, USA
Glory to Constitutional American Republic Forever! ;)
#SICSEMPERTYRANNIS

TruthSword
Joomla! Intern
Joomla! Intern
Posts: 70
Joined: Sat Feb 15, 2020 12:48 am

Re: I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem!

Post by TruthSword » Fri May 27, 2022 6:37 am

SharkyKZ,

I guess I spoke too fast. It solved the variable -> value issue. However it did not install correctly. I get this error when clicking on "Components - Mywalks"

Code: Select all

An error has occurred.
0 Class "J4xdemos\Component\Mywalks\Administrator\Extension\MywalksComponent" not found
I checked the com_mywalks\ and no such folders exist. o_O

Best Regards,

Brandon
SharkyKZ wrote:
Sun May 01, 2022 8:28 am
It' an installable package. You can install it normally using Extension Manager.
If for some reason you want to use Discover Install, you need to place files from admin directory and the mywalks.xml file in administrator/components/com_mywalks, and files from site directory in components/com_mywalks.
Best Regards,

Mr. Brandon Kastning
Washington State, USA
Glory to Constitutional American Republic Forever! ;)
#SICSEMPERTYRANNIS

TruthSword
Joomla! Intern
Joomla! Intern
Posts: 70
Joined: Sat Feb 15, 2020 12:48 am

Re: I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem!

Post by TruthSword » Fri May 27, 2022 6:43 am

Do you know if this is referring to database information? I created a secondary database separate from the Joomla Installation. a) Because I didn't think about it being a problem. and b) Now that it doesn't work; I have to learn why.

This is in administrator/components/com_mywalks/

Code: Select all

GNU nano 5.4                                                          MywalksController.php                                                                   

/**
 * Mywalks list controller class.
 *
 * @since  1.6
 */
class MywalksController extends AdminController
{
        /**
         * Proxy for getModel.
         *
         * @param   string  $name    The model name. Optional.
         * @param   string  $prefix  The class prefix. Optional.
         * @param   array   $config  The array of possible config values. Optional.
         *
         * @return  \Joomla\CMS\MVC\Model\BaseDatabaseModel
         *
         * @since   1.6
         */
        public function getModel($name = 'Mywalk', $prefix = 'Administrator', $config = array('ignore_request' => true))
        {
                return parent::getModel($name, $prefix, $config);
        }
}
I see $name & $prefix (Doesn't look like a full sql connection string at all).

This is going to be a learning curve from standard PHP it seems.

Best Regards,

Brandon
Best Regards,

Mr. Brandon Kastning
Washington State, USA
Glory to Constitutional American Republic Forever! ;)
#SICSEMPERTYRANNIS

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2523
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem!

Post by SharkyKZ » Fri May 27, 2022 7:39 am

This method is for getting a model instance. To create a database connection use Joomla\Database\DatabaseFactory::getDriver(). You can then pass it to the model in the $config array.

User avatar
ceford
Joomla! Ace
Joomla! Ace
Posts: 1567
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem!

Post by ceford » Fri May 27, 2022 7:42 am

Do not use a separate database unless you know exactly what you are doing and have good reason to!

The getModel function simply tells the application to use the model found in administrator/com_mywalks/src/Model/MywalkModel.php - you can see a similar construction in com_content/src/Controller/ArticlesController.php. The only direct reference to a database table is in src/Table/xxx.php.

TruthSword
Joomla! Intern
Joomla! Intern
Posts: 70
Joined: Sat Feb 15, 2020 12:48 am

Re: I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem!

Post by TruthSword » Fri May 27, 2022 8:27 am

SharkyKZ,

Thank you ! I will learn this.

Best Regards,

Brandon :D
SharkyKZ wrote:
Fri May 27, 2022 7:39 am
This method is for getting a model instance. To create a database connection use Joomla\Database\DatabaseFactory::getDriver(). You can then pass it to the model in the $config array.
Best Regards,

Mr. Brandon Kastning
Washington State, USA
Glory to Constitutional American Republic Forever! ;)
#SICSEMPERTYRANNIS

TruthSword
Joomla! Intern
Joomla! Intern
Posts: 70
Joined: Sat Feb 15, 2020 12:48 am

Re: I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem!

Post by TruthSword » Fri May 27, 2022 8:28 am

ceford,

Security is reason (It's a good one also!). Thank you again for the Tutorial and for the information you just provided me to learn.

Best Regards,

Brandon :D
ceford wrote:
Fri May 27, 2022 7:42 am
Do not use a separate database unless you know exactly what you are doing and have good reason to!

The getModel function simply tells the application to use the model found in administrator/com_mywalks/src/Model/MywalkModel.php - you can see a similar construction in com_content/src/Controller/ArticlesController.php. The only direct reference to a database table is in src/Table/xxx.php.
Best Regards,

Mr. Brandon Kastning
Washington State, USA
Glory to Constitutional American Republic Forever! ;)
#SICSEMPERTYRANNIS

izm_ka
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Dec 16, 2008 7:16 am

Re: I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem!

Post by izm_ka » Wed Feb 08, 2023 5:49 pm

I'm playing with MyWalks component as well, and added button to download a report file. Could someone help with how to change Controller or Router to call FilesModel::downloadfile? I have similar working plugin in Joomla 3, and trying to learn how to do a file download in Joomla 4.

izm_ka
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Dec 16, 2008 7:16 am

Re: I'm working on doing ceford's Joomla 4x Component Tutorial (com_mywalks); and ran into a problem!

Post by izm_ka » Mon Feb 13, 2023 11:48 pm

I have figured it out - I just added in the Controller:

Code: Select all

	public function download()
	{
		$cid = $this->input->get('cid');

		// get file details from DB for the $cid[0] parameter, read it from disk and return
		// ... omitted a few lines for brevity

		header("Content-Disposition: attachment; filename=$name");
		header("Content-length: $size");
		header("Content-type: $type");
		readfile($filePath);
	}


Post Reply

Return to “Joomla! 4.x Coding”