WebsiteBaker Community Forum

WebsiteBaker Support (2.12.x) => Modules => Topic started by: CodeALot on February 04, 2020, 12:02:09 PM

Title: CKEditor WBLink does not detect modules
Post by: CodeALot on February 04, 2020, 12:02:09 PM
Hi all. There used to be a solution to add different modules (Bakery, Topics, OneForAll) to the pages.php file in /modules/ckeditor/ckeditor/plugins/wblink

This pages.php-file has changed, and now there is a code block (starting at line 225 in pages.php) that should detect all available modules to build WBLinks from:
"/* --- begin: crawl all available page-addons for additional lists -------------------- */"

This however does not work. I have tested this with a fresh install of OneForAll, but the WBLink plugin fails to detect the pages made by that OneForAll-module.

Like I said: there was a workaround in the old version of CKeditor, but that does not work anymore. Anyone any idea?
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 04, 2020, 12:55:08 PM
Additional info: WBLink DOES detect items of a section of the NEWS module.
It fails however to 'detect' OneForAll-records.
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 04, 2020, 01:23:45 PM
Never mind. The problem lays deeper than this. It has to do with the new features in WB 2.12.2, like in the announcement:

Added WBLink format [wblink14?addon=news&item=153] to work with addons like news, topics, bakery and so on

It works for News. It does not work for OneForAll.
The link is returned as "#"

For instance, I am on www.mysite.com/pages/home.php
On that page I want to link to page ID 30, which has a OneForAll section. That link should be www.mysite.com/pages/newpage/oneforallitem1.php

Code: [Select]
<a href="[wblink30?addon=oneforall&amp;item=1]">Linktext</a>
But it results in a link to: www.mysite.com/pages/home.php/#
 
Looks like it's too complex to solve. I'll work around it.
Title: Re: CKEditor WBLink does not detect modules
Post by: crnogorac081 on February 04, 2020, 04:33:28 PM
You need to create separate droplet for this. For example [ofa-30]  i have this for  custom addon..
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 04, 2020, 05:21:46 PM
You need to create separate droplet for this. For example [ofa-30]  i have this for  custom addon..
That would be a workaround, but not for the client. They want to select a page and then a single record. Just like they can do with Bakery, News and Topics-items. It won't work for OneForAll. :-(
Title: Re: CKEditor WBLink does not detect modules
Post by: crnogorac081 on February 04, 2020, 06:36:40 PM
So either to modify plugin to eork with ofa (easier way) or to create another button in ckeditor for ofa. Either way you must create droplet that create reverse link from [ofa-id] to real link..
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 04, 2020, 08:53:00 PM
So either to modify plugin to eork with ofa (easier way) or to create another button in ckeditor for ofa. Either way you must create droplet that create reverse link from [ofa-id] to real link..
True. Can you give me the code for your droplet? I know it's not exactly for my situation, but it may serve as a good starting point :)
Title: Re: CKEditor WBLink does not detect modules
Post by: crnogorac081 on February 05, 2020, 09:40:11 AM
Hello,

here is solution for OFA.

rename .txt to .php and place to OFA folder


Can someone link this to original topic, https://forum.WebsiteBaker.org/index.php/topic,27895.275.html  because its locked.

Also it would be good to include in original OFA module page from WB addon repository
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 05, 2020, 09:55:12 AM
Very nice, thank you!
Still work in progress though, I'm afraid.
 
In CKEditor I now get the dropdown-list with all the OneForAll items, so that is great.
In the source code, I can see how the item is 'called', for instance:

Code: [Select]
<a href="[wblink23?addon=oneforall&amp;item=27]">OFA item</a>
However, when it's saved, and I check the live page (frontend) and the link is turned into

Code: [Select]
<a href="#">OFA item</a>
I must add: I use ShortURL. Maybe that's causing problems?
Title: Re: CKEditor WBLink does not detect modules
Post by: dbs on February 05, 2020, 09:58:50 AM
Hi, the dialog is now like it should. But the generated link works not for me.
Looks like
Code: [Select]
<a href="[wblink58?addon=oneforall&amp;item=9]">In frontend i see as link the same page with a # at the end.
mydomain.de/de/current-page#  (yes, with shorturl)

Is there something to do except rename/upload the one file?
Title: Re: CKEditor WBLink does not detect modules
Post by: crnogorac081 on February 05, 2020, 10:05:21 AM
I will take a look, hovewer i never used OFA module before
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 05, 2020, 10:21:02 AM
I will take a look, hovewer i never used OFA module before
Oh man, you should. Can't do without anymore :-) Thanks for your efforts!
 
EDIT: I installed a fresh WB 2.12.2 without ShortURL and the problem stays as described above here by dbs and me:
In CKEditor source, the link looks ok. In the frontend, the link is replaced by a single "#".
Title: Re: CKEditor WBLink does not detect modules
Post by: dbs on February 05, 2020, 10:41:48 AM
This # comes from WbLinkAbstract.php line 119
Code: [Select]
// set link on failure ('#' means, still stay on current page)
        $sRetval = '#';
Seems the following sql query has no result.
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 05, 2020, 11:07:15 AM
This # comes from WbLinkAbstract.php line 119
Code: [Select]
// set link on failure ('#' means, still stay on current page)
        $sRetval = '#';
Seems the following sql query has no result.

The same WbLinkAbstract.php is called when you want to link to an item in a News-module, and then it works OK. It fails for OFA, and I can't find why... :(
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 05, 2020, 11:35:52 AM
Ok, I now see what's happening. Looking at the output of WbLinkAbstract.php, I get the following:

SQL call for a news post:
Code: [Select]
SELECT `link` FROM `wb_mod_news_posts` WHERE `post_id`=1Resulting URL:
Code: [Select]
/posts/breaking-news-1-1
This works fine.

SQL for an OFA item:
Code: [Select]
SELECT `link` FROM `wb_mod_oneforall_items` WHERE `item_id`=1Resulting URL:
Code: [Select]
/first-item
And that URL is NOT valid since it does not have the full link-path (in this case, it should have been oneforall-page/first-item )
 
This causes WbLinkAbstract to fail when checking the URL and returning the # instead of the actual link.
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 05, 2020, 12:12:26 PM
The source of the problem is the fact that OneForAll does not populate the "link"-field with the actual full link with the /pages/ directory as a base. It only saves the page-url, not the path.

So, the only way to fix this is to alter WbLinkAbstract.php in such a way that:


...and I can't get that to work properly :-(
Title: Re: CKEditor WBLink does not detect modules
Post by: crnogorac081 on February 05, 2020, 12:15:05 PM
hello,

In OFA module file , WBReorg.php  line 50

    const ACCESSFILES_SUBDIR   = '';

change to

    const ACCESSFILES_SUBDIR   = '/ofa';  or whatever ofa item folder is in /Pages

someone test
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 05, 2020, 12:37:04 PM
hello,

In OFA module file , WBReorg.php  line 50

    const ACCESSFILES_SUBDIR   = '';

change to

    const ACCESSFILES_SUBDIR   = '/ofa';  or whatever ofa item folder is in /Pages

someone test

Tested. Does not do anything, it seems.
Title: Re: CKEditor WBLink does not detect modules
Post by: crnogorac081 on February 05, 2020, 12:45:40 PM
if you have for example OFA item id = 1, what is his real path from /pages direcotry ??   root/pages/ofa/item-link-1.php ?
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 05, 2020, 12:54:31 PM
if you have for example OFA item id = 1, what is his real path from /pages direcotry ??   root/pages/ofa/item-link-1.php ?

Correct.

pages/ofa-module-name/titlelink-of-ofa-item.php

What WbLinkAbstract now tries to do, is create

pages/titlelink-of-ofa-item.php
 
For my own situation, I altered WbLinkAbstract so that it checks for the module name, and if it's the OFA-module name, it adds an extra path to the link

Code: [Select]

if ($this->oDb->TablePrefix.$this::TABLE_NAME == 'wb_mod_oneforall_items') { $extrapath="oneforall/"; }
$sLink     = $extrapath.$sLink;
Not pretty, but it works for me. There should be a more elegant way to solve this, though :-)
Title: Re: CKEditor WBLink does not detect modules
Post by: crnogorac081 on February 05, 2020, 01:08:48 PM
there are 2 lines in modules/oneforall/WBReorg.php  around line 50

Code: [Select]
/** sub directory for accessfiles
 * @description  This is needed to correct db::x_mod_table::link entries of former versions<br />
 *               let it empty without a hardcoded subdirectory name like our news addon with a
 *               hardcodet subdirectory. The root directory always will be the pages_directory.
 *               with trailing slash if not empty
 */
    const ACCESSFILES_SUBDIR   = '';

/** root directory for accessfiles */
    protected $sAccessFilesRoot = '';


But no matter if I change to

    const ACCESSFILES_SUBDIR   = '/ofa';

or
    protected $sAccessFilesRoot = '/ofa';
or both of them as /ofa

it want work... Wierd..
Title: Re: CKEditor WBLink does not detect modules
Post by: johnbroeckaert on February 06, 2020, 07:21:35 PM
I got this solution from Jacobi22
Works fine for me...

Try it for yourself and let me/us Know.....
CHEERS
Title: Re: CKEditor WBLink does not detect modules
Post by: dbs on February 06, 2020, 11:39:11 PM
Works also for me. Thanks.  (Y)
In my case
Code: [Select]
const ACCESSFILES_SUBDIR   = 'de/listen/oneforall';
edit: it works not if you have the same module on another (sub)page.
Title: Re: CKEditor WBLink does not detect modules
Post by: crnogorac081 on February 07, 2020, 06:15:35 PM
Someone tell me what is difference between

const ACCESSFILES_SUBDIR   = '';
And
    protected $sAccessFilesRoot = '';

Where are they used.. it seems to me this is same..

But stil, const can not be changed, and
$sAccessFilesRoot  could be changed dinamicly ,something like $sAccessFilesRoot = $language.'/ofa/';  right ?
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 07, 2020, 11:06:17 PM
I tried the posted WbLink.php and that works, as long as you don't use the same OFA module on different pages.
Title: Re: CKEditor WBLink does not detect modules
Post by: crnogorac081 on February 08, 2020, 09:51:32 PM
So ine of theese two

const ACCESSFILES_SUBDIR   = '';
And
    protected $sAccessFilesRoot = '';


Could be array ( different url path for different pages)  then to chech if not empty - foreach  - chech if php file exists..
Title: Re: CKEditor WBLink does not detect modules
Post by: dbs on February 11, 2020, 09:19:34 AM
No idea for dynamically pages dir.

But a question. Can it be, the wblink.php for a ofa with a directory name like "my_ofa" (module name: my ofa) will not work?
Seems the underscore (maybe also the hyphen in /pages/my-ofa) is a problem.
Title: Re: CKEditor WBLink does not detect modules
Post by: CodeALot on February 11, 2020, 09:48:06 AM
No idea for dynamically pages dir.

But a question. Can it be, the wblink.php for a ofa with a directory name like "my_ofa" (module name: my ofa) will not work?
Seems the underscore (maybe also the hyphen in /pages/my-ofa) is a problem.

Can't tell you if that would be a problem. I don't use any hyphens or underscores in module names anymore, just to avoid problems like that :)