Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block links redirect and Highlight Issue in OPS 3.3 #7

Open
talknshare opened this issue May 13, 2022 · 6 comments
Open

Block links redirect and Highlight Issue in OPS 3.3 #7

talknshare opened this issue May 13, 2022 · 6 comments

Comments

@talknshare
Copy link

I use OPS 3.3.0.10 and faced the issue where the hyperlinks for categories in the browse block does not redirect correctly.

I changed the word "catalog" to "preprints" in browse/templates/block.tpl on line 29 and it worked:
<a href="{url router=\PKP\core\PKPApplication::ROUTE_PAGE page="**catalog**" op="category" path=$browseCategory->getPath()|escape}">

Another issue with category highlight when after clicking a category in the browse block after opening the page. I changed the word "catalog" to "preprints" again in browse/browseBlockPlugin.php file on line 55 and it fixed it:
if ($router->getRequestedPage($request) . '/' . $router->getRequestedOp($request) == '**catalog**/category') {

I still cannot figure out where do I see a page/link with the list of all categories only on one page. Please let me know if you can help!

@asmecher
Copy link
Member

@talknshare, would you be able to open a pull request with those two changes included? (Tagging @ajnyga -- I suspect this is related to some renames of OJS-specific language that went in a little while ago.)

@talknshare
Copy link
Author

Thank you, @asmecher. I hope I have created the pull requests correctly. Just FYI, I used the OPS 3.3.0.10 to test the browse block to replicate.

@asmecher
Copy link
Member

@asmecher
Copy link
Member

@talknshare, got them, thanks! However, this plugin is used both with OJS and OPS, and would need to work in both scenarios. You can check which application you're in by calling Application::getName() and checking if it returns ojs2 or ops.

@talknshare
Copy link
Author

@asmecher Understood. Can you tell me where should I type the aforementioned command "Application::getName()" to check the application running? I use a VPS service, and have access to the cPanel terminal but not really sure where do I run the command line. Thanks!

@asmecher
Copy link
Member

@talknshare, this is in the plugin code -- your changes would fix OPS, but break OJS. You'll need to check the result of Application::getName() to know which case applies. For example, instead of:

diff --git a/BrowseBlockPlugin.php b/BrowseBlockPlugin.php
index 2c1e94e..05dc29a 100644
--- a/BrowseBlockPlugin.php
+++ b/BrowseBlockPlugin.php
@@ -52,7 +52,7 @@ public function getContents($templateMgr, $request = null)
         $router = $request->getRouter();
 
         $requestedCategoryPath = null;
-        if ($router->getRequestedPage($request) . '/' . $router->getRequestedOp($request) == 'catalog/category') {
+        if ($router->getRequestedPage($request) . '/' . $router->getRequestedOp($request) == 'preprints/category') {
             $args = $router->getRequestedArgs($request);
             $requestedCategoryPath = reset($args);
         }

...it would be something like the following (untested)...

diff --git a/BrowseBlockPlugin.php b/BrowseBlockPlugin.php
index 2c1e94e..43e4856 100644
--- a/BrowseBlockPlugin.php
+++ b/BrowseBlockPlugin.php
@@ -52,7 +52,11 @@ class BrowseBlockPlugin extends BlockPlugin
         $router = $request->getRouter();
 
         $requestedCategoryPath = null;
-        if ($router->getRequestedPage($request) . '/' . $router->getRequestedOp($request) == 'catalog/category') {
+        $pageName = match(Application::getName()) {
+                'ojs2' => 'catalog',
+                'omp' => 'preprints',
+        };
+        if ($router->getRequestedPage($request) . '/' . $router->getRequestedOp($request) == "$pageName/category") {
             $args = $router->getRequestedArgs($request);
             $requestedCategoryPath = reset($args);
         }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants