Author Topic: Use 'WBLINK' in CkEditor to jump to News articles, Bakery-items or OFA-records  (Read 695 times)

Offline CodeALot

  • Posts: 353
  • Gender: Male
Wouldn't it be nice if...

we could have a WBLINK-functionality in CKEditor to not just select pages that exist in WB but also directly to news-articles and records in the OneForAll-modules?
 
As it is now, my clients can only do "full URL-links" to an item in Bakery, for instance. They will have to navigate to that article, copy the URL of that article, and use that URL in another page to link directly to it.

Hope you understand what I mean :)

Offline jacobi22

  • Global Moderator
  • *****
  • Posts: 4454
  • Gender: Male
    • Jacobi22
a function like this is part of the actual CKEditor-versions, it was a hard-coded solution and worked only for the defined addons, it was not dynamical.
i 've not tested this function for other modules, but you can see it in modules/ckeditor/ckeditor/plugins/wblink/pages.php and other modules, if you need





in a new version CKeditor WB for WB 2.8.4 was anew dynamical solution, but its not possible to use it in wb 2.8.3 without changes in the system
« Last Edit: February 06, 2017, 11:13:58 AM by jacobi22 »
Du bist der Mensch, der mich zum Lachen bringt und der, der mit mir weint. Ich muss lachen, wenn du lachst und weinen, wenn du weinst und darum wirst du für immer ein Teil von meinem Herzen sein
(*miss you*)

Offline CodeALot

  • Posts: 353
  • Gender: Male
I think I'll make wishes moreoften in the forum, they are granted instantly! :-) Thanks for pointing me in the right direction!

Offline jacobi22

  • Global Moderator
  • *****
  • Posts: 4454
  • Gender: Male
    • Jacobi22
testet in WB 2.10.0-RC1 and Bakery 1.78 and latest CKeditor-Version- works without problems



if you need the same for oneforall, go to modules/ckeditor/ckeditor/plugins/wblink/pages.php and look to the different blocks for news, topics or bakery

copy one of this block and change the code in different places, so, that its run for ofa also

but be carefull... if OFA doesnt use subpages for the items, maybe the whole wblink-plugin doesnt work then
Du bist der Mensch, der mich zum Lachen bringt und der, der mit mir weint. Ich muss lachen, wenn du lachst und weinen, wenn du weinst und darum wirst du für immer ein Teil von meinem Herzen sein
(*miss you*)

Offline CodeALot

  • Posts: 353
  • Gender: Male
Unfortunately this does not seem to work (anymore) for OFA. I reads the link but fails to add the subdirectory.

So when a OFA item is located in  /pages/projects/domestic/this-is-a-link-to-the-page.php
the pages.php/WBLink-module creates a link: /pages/projects//this-is-a-link-to-the-page.php

...and that won't work :(
I used the block for Bakery to change the module-name, so it should work similar.... Any suggestions about what I might be overlooking?

Offline jacobi22

  • Global Moderator
  • *****
  • Posts: 4454
  • Gender: Male
    • Jacobi22
is a little bit tricky, because, its possible, to give a new module name for OFA and a hardcoded solution doesnt work then.

here a how-to for OFA - WBLinks

1. go to modules / ckeditor / ckeditor / plugins / wblink / lang / en.js  and all in the backend used languages (for example: i use also german, so i have to edit the file de.js also
add here a new selectionTitle (Top-Entry in the select-Box if nothing selected)

nearly at the end of the array
Code:
Only registered users can see contents. Please click here to Register or Login.
if you use a different OFA-name, add one line more with this name like (your Example)
Code:
Only registered users can see contents. Please click here to Register or Login.

2. add this block in modules / ckeditor / ckeditor / plugins / wblink / pages.php

Code:
Only registered users can see contents. Please click here to Register or Login.
if you work with multiple OFA's, copy this Codeblock and change the module name in Line 1 and 2, in the select $ofaitems and in the linkbuilder at the end

the linkbuilder
Quote
$NewsItemsSelectBox .= "NewsItemsSelectBox[".$section['page_id']."][NewsItemsSelectBox[".$section['page_id']."].length] = new Array('".(addslashes($item['title']))."', '".WB_URL.PAGES_DIREC TORY."/oneforall".(addslashes($item['link'])).PAGE_EXTENSION."');";

this line here is the title in the selectbox (see #1). be sure, that you use the same word in the language file (case-sensitive). its important to clear the cache after changing something in the js-files to see the effect

pages.php
Quote
$ModuleList .= "ModuleList[".$section['page_id']."] = 'Oneforall';";

en.js
Quote
selectOneforall: 'Please select a oneforall-item',

P.S.: solution is tested with WB 2.10.x, CKEditor 4.6.2 and PHP 7.1.8 + PHP 7.1.5



AdminEdit (by jacobi22): change the code-block for modules / ckeditor / ckeditor / plugins / wblink / pages.php
« Last Edit: July 27, 2017, 01:40:41 PM by jacobi22 »
Du bist der Mensch, der mich zum Lachen bringt und der, der mit mir weint. Ich muss lachen, wenn du lachst und weinen, wenn du weinst und darum wirst du für immer ein Teil von meinem Herzen sein
(*miss you*)

Offline jacobi22

  • Global Moderator
  • *****
  • Posts: 4454
  • Gender: Male
    • Jacobi22
 :oops: :oops: :oops: somethink goes wrong...  :oops: :oops: :oops:
in my test's i use one ofa directly in the pages-directory - that works
but, if i use it as subpage in a third level, the link is not correct, the path has no parents. i'll look at this and edit my post later

Sorry  :cry: :cry:
Du bist der Mensch, der mich zum Lachen bringt und der, der mit mir weint. Ich muss lachen, wenn du lachst und weinen, wenn du weinst und darum wirst du für immer ein Teil von meinem Herzen sein
(*miss you*)

Offline CodeALot

  • Posts: 353
  • Gender: Male
Thanks a lot for the time and effort! Implemented it and it works (I just added the path to the pathbuilder :) )

Offline jacobi22

  • Global Moderator
  • *****
  • Posts: 4454
  • Gender: Male
    • Jacobi22
i change the code in post #5 to set the path for ofa-pages, if you have it in a sub-directory. maybe you can try it again
Du bist der Mensch, der mich zum Lachen bringt und der, der mit mir weint. Ich muss lachen, wenn du lachst und weinen, wenn du weinst und darum wirst du für immer ein Teil von meinem Herzen sein
(*miss you*)

Offline dbs

  • Betatester
  • **
  • Posts: 6921
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
I have 2 ofa sections added (different modules).
In pages.php one ofa is a copy of bakery block, changed to the new module name (4x + Modulelist + pagename in linkbuilder line).
The other one is a copy of your code block here, changed to the new module name (4x + Modulelist).
The 284 part could be removed, than only 3x replacements.

Both works in wb2.10 php7.1.7 (not subfolder).
Therefore your code here is a little bit better. Thanks for that.

Offline jacobi22

  • Global Moderator
  • *****
  • Posts: 4454
  • Gender: Male
    • Jacobi22
bakery and topics use a special folder in the defined PAGES_DIRECTORY, doesnt matter, where you use the module in your page tree. ofa builds a childfolder behind the ofa-page. if you use ofa in the 3. level, all items of this page are in level 4, but the copied code-block in pages.php give's only the link to the root of PAGES_DIRECTORY and has no path to other levels
Du bist der Mensch, der mich zum Lachen bringt und der, der mit mir weint. Ich muss lachen, wenn du lachst und weinen, wenn du weinst und darum wirst du für immer ein Teil von meinem Herzen sein
(*miss you*)

Offline CodeALot

  • Posts: 353
  • Gender: Male
i change the code in post #5 to set the path for ofa-pages, if you have it in a sub-directory. maybe you can try it again

I will! Sorry for not responding earlier. I'll keep you posted!

 

postern-length