Class Headers not being added for subsequent dynamic gets #998

Closed
opened 2023-05-26 04:28:24 +00:00 by Chris Paschen · 5 comments
Member

Steps to reproduce the issue

  1. Create a new Power
  2. Create a Dynamic Get & Site View (that are related and added to the component) [name 'course']
  3. Add the new power (along with a few other use statements) to the Class Header (Target Site View Model Header)
  4. Compile
    OK ... it works and the use statements are added to the top of the model
  5. Add another Dynamic Get & Site View (also related to each other and added to the component) [name 'courselist']
  6. Add that same power and similar use statements in the Class Header area
  7. Compile

Expected result

The use statements (both manual and the new power/class) should appear at the top of both model files ('course' and 'courselist').

Actual result

The use statements (both manual and the new power/class) appear in the first one ('course') but not in the second ('courselist').

System information (as much as possible)

  • OS Name & Version: WAMP
  • MySql Version: 5.7.40
  • Apache Version: 2.4.54.2
  • PHP Version: 8.0.26
  • Joomla Version: 3.10.11
  • JCB Version: 3.1.12 (same results on 3.1.24)
  • Browser: Firefox Developer

Additional comments

I've tried a number of different things:

  • Adding only a manual 'use' entry ('use Joomla\CMS\Factory;') without a Power Header has the same result (no header added)
  • Adding only a Power Header - same thing, no header added
  • Adding some code in the "Add PHP after getting the items" section - no header added
  • Tried added the Power Header with both 'Based on Component' and 'Always'
  • Tried adding Class headers to Admin views and same results
  • Making changes to the original ('course') header DOES work (any changes DO show up upon compile) [remove the Power Header - it's gone; add it back in - it's there again]

The helper file is getting the line "spl_autoload_register(function ($class)) " added. And the initial ('course') dynamic get is able to use the methods of the class as it should.

This is very strange that it basically just disabled the Class Header functionality for any view/dynamic get other than the one that it was associated with when the Power Header was added.

This is the first time I've used Powers on a JCB component, so maybe I missed something, but I thought that I could just create a power then manually add it to the header of each view/get so that I could use the class when needed.

I've watched the Powers Youtube video "JCB Powers Area Demonstrated" as well as the recent Super-powers videos; but I'm not seeing that I've missed something. Esp. considering it is working fine for the ONE dynamic get.

Is there something that I have missed?

### Steps to reproduce the issue 1. Create a new Power 2. Create a Dynamic Get & Site View (that are related and added to the component) [name 'course'] 3. Add the new power (along with a few other use statements) to the Class Header (Target Site View Model Header) 4. Compile OK ... it works and the use statements are added to the top of the model 5. Add another Dynamic Get & Site View (also related to each other and added to the component) [name 'courselist'] 6. Add that same power and similar use statements in the Class Header area 7. Compile ### Expected result The use statements (both manual and the new power/class) should appear at the top of both model files ('course' and 'courselist'). ### Actual result The use statements (both manual and the new power/class) appear in the first one ('course') but not in the second ('courselist'). ### System information (as much as possible) - OS Name & Version: WAMP - MySql Version: 5.7.40 - Apache Version: 2.4.54.2 - PHP Version: 8.0.26 - Joomla Version: 3.10.11 - JCB Version: 3.1.12 (same results on 3.1.24) - Browser: Firefox Developer ### Additional comments I've tried a number of different things: * Adding only a manual 'use' entry ('use Joomla\CMS\Factory;') without a Power Header has the same result (no header added) * Adding only a Power Header - same thing, no header added * Adding some code in the "Add PHP after getting the items" section - no header added * Tried added the Power Header with both 'Based on Component' and 'Always' * Tried adding Class headers to Admin views and same results * Making changes to the original ('course') header DOES work (any changes DO show up upon compile) [remove the Power Header - it's gone; add it back in - it's there again] The helper file is getting the line "spl_autoload_register(function ($class)) " added. And the initial ('course') dynamic get is able to use the methods of the class as it should. This is very strange that it basically just disabled the Class Header functionality for any view/dynamic get other than the one that it was associated with when the Power Header was added. This is the first time I've used Powers on a JCB component, so maybe I missed something, but I thought that I could just create a power then manually add it to the header of each view/get so that I could use the class when needed. I've watched the Powers Youtube video "JCB Powers Area Demonstrated" as well as the recent Super-powers videos; but I'm not seeing that I've missed something. Esp. considering it is working fine for the ONE dynamic get. Is there something that I have missed?
Owner

JCB version 3.1.12 and 3.1.24 has a code difference of 20k lines of code. There is no way that they are the same. The new super powers are only fully stable from 3.1.24 (at least)

Further more it is very hard to make sense (from reading your comments) of what your doing without seeing pictures/screen-shots of the areas in question.

JCB has the same classes added to many different views, and as a result we know it works correctly. It is for that reason you will need to give more detailed screen-shots of what your doing.

JCB version 3.1.12 and 3.1.24 has a code difference of 20k lines of code. There is no way that they are the same. The new super powers are only fully stable from 3.1.24 (at least) Further more it is very hard to make sense (from reading your comments) of what your doing without seeing pictures/screen-shots of the areas in question. JCB has the same classes added to many different views, and as a result we know it works correctly. It is for that reason you will need to give more detailed screen-shots of what your doing.
Author
Member

OK ... just knowing that it should work, I'll work on trying to do some more testing here (including migrating to 3.1.24).
I'm going to close this for now.

OK ... just knowing that it should work, I'll work on trying to do some more testing here (including migrating to 3.1.24). I'm going to close this for now.
Author
Member

OK ... I created a new clean Joomla instance, installed JCB 3.1.24 and then exported this project from the old site (which had a JCB instance that had been upgraded many times over the past couple years), and imported the project into this new Joomla/JCB instance, and getting the same problem.

So here is a step-by-step explanation of what I'm doing and getting:

  1. Made sure that all the JCB Plugins were enabled
    01 - SETUP - All JCB Plugins enabled.png

  2. Made sure that the JCB compile options were activated
    01b - JCB OPTIONS -  Activate Compiler Plugins Included.png

  3. Created a new Power

Main settings:
02a - POWER - Create new power.png

Additional settings:
02b - POWER - Create new power.png

  1. Added the power to the Class Headers area of the first Dynamic Get (course - singular)
    03a - Dyanmic Get - Class Headers - Course.png

(continuing on next entry)

OK ... I created a new clean Joomla instance, installed JCB 3.1.24 and then exported this project from the old site (which had a JCB instance that had been upgraded many times over the past couple years), and imported the project into this new Joomla/JCB instance, and getting the same problem. So here is a step-by-step explanation of what I'm doing and getting: 1. Made sure that all the JCB Plugins were enabled ![![01 - SETUP - All JCB Plugins enabled.png](/attachments/28a158db-05ce-4588-b6e8-0d0e742e801c)](https://) 2. Made sure that the JCB compile options were activated ![01b - JCB OPTIONS - Activate Compiler Plugins Included.png](/attachments/a5776395-1f79-4a60-9a1b-d0962c480afd) 3. Created a new Power Main settings: ![02a - POWER - Create new power.png](/attachments/98c4ac4f-2f36-4d0a-80e0-6dfad44e400c) Additional settings: ![02b - POWER - Create new power.png](/attachments/9f40dc84-c20e-47d0-9538-2a3dac4a26b8) 4. Added the power to the Class Headers area of the first Dynamic Get (course - singular) ![03a - Dyanmic Get - Class Headers - Course.png](/attachments/f12bb6fe-daf4-49f6-88e2-6526963c158d) (continuing on next entry)
Author
Member

(continued from previous)

  1. Added the power to the Class Headers area of the second Dynamic Get (courses - multiple/list view) NOTE: Also added a manual 'use Joomla\CMS\Factory' entry AND set the Power Header build to 'Always' (but I've tried with other settings as well)
    03b - Dyanmic Get - Class Headers - Courses.png

  2. Compiled the component

  3. RESULTS:

In the course (singular) it results in the power being added to the header uses area:
04 - COMPILED - model - course.PNG

In the courses (multiple/list-view) it results in NONE of the class headers being added (neither the power or the manual use-factory line)
04b - COMPILED - model - courses.PNG

When trying to use the class in the courses model, I get a Class not found error.

Not sure what else I should be doing to get the class/power (as well as the other use headers) to be added.
I've watched the JCB Powers Area Demonstrated youtube video several times and can't seem to find any reason why the headers are not being added to any other area of my component other than this one dynamic get (course).

Any ideas where to look for a possible setting or something else that might be causing these headers to not be added?

(continued from previous) 5. Added the power to the Class Headers area of the second Dynamic Get (courses - multiple/list view) NOTE: Also added a manual 'use Joomla\CMS\Factory' entry AND set the Power Header build to 'Always' (but I've tried with other settings as well) ![03b - Dyanmic Get - Class Headers - Courses.png](/attachments/315298d5-58fd-4da4-a78e-3a36cb5480bb) 6. Compiled the component 7. RESULTS: In the course (singular) it results in the power being added to the header uses area: ![04 - COMPILED - model - course.PNG](/attachments/0dfc153f-bce4-48c3-ad2b-3cf7f9a23635) In the courses (multiple/list-view) it results in NONE of the class headers being added (neither the power or the manual use-factory line) ![04b - COMPILED - model - courses.PNG](/attachments/98a2d369-31b2-4704-a9be-cef383ef899a) When trying to use the class in the courses model, I get a Class not found error. Not sure what else I should be doing to get the class/power (as well as the other use headers) to be added. I've watched the JCB Powers Area Demonstrated youtube video several times and can't seem to find any reason why the headers are not being added to any other area of my component other than this one dynamic get (course). Any ideas where to look for a possible setting or something else that might be causing these headers to not be added?
Author
Member

(OK Dumb user error)

After trying all sorts of things, including trying to add this to the header of various other views, I found it was being added to some and not others.

When I tried to identify what the differences where when the headers were or were not being added I noticed that it was the type of dynamic get.

They were being added to all the getItem, but not any of the getListQuery gets.

So I looked again at the Class Headers ... and noticed that there is both:

  • Target Site VIEW Model Header
  • Target Site VIEWS Model Header

I guess the bold 'getItem' wasn't enough to make that clear (maybe if they weren't initially collapsed and I would have seen the bold getListQuery I would have noticed :-o

So all is working properly, just needed to switch the location where the class header was added.

(OK Dumb user error) After trying all sorts of things, including trying to add this to the header of various other views, I found it was being added to some and not others. When I tried to identify what the differences where when the headers were or were not being added I noticed that it was the type of dynamic get. They were being added to all the getItem, but not any of the getListQuery gets. So I looked again at the Class Headers ... and noticed that there is both: * Target Site VIEW Model Header * Target Site VIEWS Model Header I guess the bold 'getItem' wasn't enough to make that clear (maybe if they weren't initially collapsed and I would have seen the bold getListQuery I would have noticed :-o So all is working properly, just needed to switch the location where the class header was added.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 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#998
No description provided.