Jump to content

[Solved] Problem with Block Development Shortcuts (Windows issue again?)


iank
 Share

Recommended Posts

Hi @bernhard,

I've just encountered another issue, possibly because I'm working locally with Windows.  The vscode block development shortcuts for Superusers aren't linking to the block view and block php files.  Specifically these:

blockshortcuts.png.019cf2a7cfcaaf7e9d4707ca983cfb66.png

They seem to both default to pointing at the  \site\modules\RockFrontend\RockFrontend.module.php rather than the individual block/view files.  

I'm not sure why; maybe it's a difference in the information that debug_backtrace() returns on a Windows system?  I don't know if this dump of the backtrace from getTplPath() is helpful:

The icons seem to be using the first 'file' entry, although the link to the view file is there...


242131314_System-Screenshot2023-11-24105031.png.57174aa896c5d1fd35e7d9663f4fd520.png

Thanks in advance,

Ian.

 

  • Like 1
Link to comment
Share on other sites

Almost!   Both the icons now point to the [BlockName].view.php file.

I presume one should point to the [BlockName].php and one to the [BlockName].view.php file ??

I'm just using straight PHP for my blocks, not Latte.

Thx,

Ian.

Link to comment
Share on other sites

Hey @iank thx. Unfortunately that was a wrong guess from my side and it's not really helpful. I'll be mostly offline for some days and I'll have to look into it later. If you find time to debug it yourself that would be great, because it's kinda hard to do that without a windows system from my side ? But I'll try my best when I'm back.

Link to comment
Share on other sites

Hey @bernhard,

I think I've found the problem. It's relating to the fact that the view file extension can be either .latte or .view.php (I'm using the .view.php version).  The logic for finding the php file edit link is stripping the view file extension and then adding back ".php". This works if it's a .latte view file, but not for .view.php files.  In this case, it simply strips off the last part (.php) and adds it back, so we still have the .view.php in the full path.

I added this line to ___getIcons() which fixes the problem, though there might be a more elegant solution:

$ext = pathinfo($opt->path, PATHINFO_EXTENSION);

// php file edit link; view file can be .latte or .view.php
$php = substr($opt->path, 0, strlen($ext) * -1 - 1) . ".php";
$php = str_ireplace("view.php", "php", $php);  // <============== if it's a .view.php file
  if (is_file($php)) {
  ....

Regards,

Ian.

  • Thanks 1
Link to comment
Share on other sites

  • iank changed the title to [Solved] Problem with Block Development Shortcuts (Windows issue again?)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...