CKEditor WBLink does not detect modules

CodeALot

Quote from: 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.

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 :)

dbs

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.
[url="https://onkel-franky.de"]https://onkel-franky.de[/url]

crnogorac081

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..
Web developer

CodeALot

I tried the posted WbLink.php and that works, as long as you don't use the same OFA module on different pages.

crnogorac081

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 ?
Web developer

dbs

#23
Works also for me. Thanks.  (Y)
In my case
const ACCESSFILES_SUBDIR   = 'de/listen/oneforall';

edit: it works not if you have the same module on another (sub)page.
[url="https://onkel-franky.de"]https://onkel-franky.de[/url]

johnbroeckaert

I got this solution from Jacobi22
Works fine for me...

Try it for yourself and let me/us Know.....
CHEERS

crnogorac081

there are 2 lines in modules/oneforall/WBReorg.php  around line 50


/** 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..
Web developer

CodeALot

Quote from: 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 ?

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


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 :-)

crnogorac081

if you have for example OFA item id = 1, what is his real path from /pages direcotry ??   root/pages/ofa/item-link-1.php ?
Web developer

CodeALot

Quote from: 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

Tested. Does not do anything, it seems.

crnogorac081

#17
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
Web developer

CodeALot

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:


  • The link is checked
  • If the link check fails, look for the page_title based on the page_id
  • Check if the link exists if you add page_title.'/'. before the link (which will be the case in OneForAll-sections)

...and I can't get that to work properly :-(

CodeALot

Ok, I now see what's happening. Looking at the output of WbLinkAbstract.php, I get the following:

SQL call for a news post:
SELECT `link` FROM `wb_mod_news_posts` WHERE `post_id`=1
Resulting URL:
/posts/breaking-news-1-1

This works fine.

SQL for an OFA item:
SELECT `link` FROM `wb_mod_oneforall_items` WHERE `item_id`=1
Resulting URL:
/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.

CodeALot

Quote from: dbs on February 05, 2020, 10:41:48 AM
This # comes from WbLinkAbstract.php line 119
// 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... :(

dbs

This # comes from WbLinkAbstract.php line 119
// set link on failure ('#' means, still stay on current page)
        $sRetval = '#';

Seems the following sql query has no result.
[url="https://onkel-franky.de"]https://onkel-franky.de[/url]

CodeALot

#12
Quote from: crnogorac081 on February 05, 2020, 10:05:21 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 "#".

crnogorac081

I will take a look, hovewer i never used OFA module before
Web developer

dbs

Hi, the dialog is now like it should. But the generated link works not for me.
Looks like
<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?
[url="https://onkel-franky.de"]https://onkel-franky.de[/url]

CodeALot

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:

<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

<a href="#">OFA item</a>

I must add: I use ShortURL. Maybe that's causing problems?

crnogorac081

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
Web developer

CodeALot

Quote from: 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..
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 :)

crnogorac081

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..
Web developer

CodeALot

Quote from: 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..
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. :-(

crnogorac081

You need to create separate droplet for this. For example [ofa-30]  i have this for  custom addon..
Web developer