How to open links t...
 
Notifications
Clear all

How to open links to a new window

6 Posts
2 Users
2 Reactions
118 Views
(@asaga)
Posts: 31
Trusted Member
Topic starter
 

Hi guys,

After updating my small site to Osclasspoint, i see that links in the body of the ads open to the same window and that means the visitor is out of the site. I don't want that.

Also i have a custom url field and the same issue with that.

Previously i had done some modifications i found here for some file and also for the editor. But the instructions for the editor are not the same or i miss something.

Any ideas if they work for Osclasspoint 8.1 version? Maybe i have to ask to their forums?

I would appreciate some help if you can....

Thanks

 
Posted : February 4, 2023 02:18
Editor
(@editor)
Posts: 553
Honorable Member Admin
 

Hi.

First in "oc-includes/osclass/helpers/hitems.php" find (around line 1519) find

 if($value!='') {
      if(stripos($value,'http://')!==false || stripos($value,'https://')!==false) {
        return '<a href="'.osc_esc_html(html_entity_decode($value, ENT_COMPAT, "UTF-8")).'" >'.osc_esc_html(html_entity_decode($value, ENT_COMPAT, "UTF-8")).'</a>';
      } else {
        return '<a href="http://'.osc_esc_html(html_entity_decode($value, ENT_COMPAT, "UTF-8")).'" >'.osc_esc_html(html_entity_decode($value, ENT_COMPAT, "UTF-8")).'</a>';
      }
    } else {
      return '';
    }

and change it to

    if($value!='') {
      if(stripos($value,'http://')!==false || stripos($value,'https://')!==false) {		  
        return '<a href="'.osc_esc_html(html_entity_decode($value, ENT_COMPAT, "UTF-8")).' "target="_blank" >'.osc_esc_html(html_entity_decode($value, ENT_COMPAT, "UTF-8")).'</a>';
      } else {
        return '<a href="http://'.osc_esc_html(html_entity_decode($value, ENT_COMPAT, "UTF-8")).' "target="_blank" >'.osc_esc_html(html_entity_decode($value, ENT_COMPAT, "UTF-8")).'</a>';	
      }
    } else {
      return '';
    }

This will fix the custom field url.

 
Posted : February 4, 2023 06:08
Asaga reacted
Editor
(@editor)
Posts: 553
Honorable Member Admin
 

If you need also the above to be "nofollow", check this example:

https://www.valueweb.gr/forums/osclass/make-all-posted-links-in-ads-nofollow-and-open-them-in-new-window/#post-4

 
Posted : February 4, 2023 06:17
Editor
(@editor)
Posts: 553
Honorable Member Admin
 

And here is described what you must change for the editor body links:

https://www.valueweb.gr/forums/osclass/how-to-make-links-in-a-post-to-open-in-new-window/

In "oc-includes/osclass/functions.php" find

function osc_tinymce_item_script()

and before the line

plugins : [

add

extended_valid_elements : "a[href|target=_blank|rel=nofollow]",

Let me know if this works for you and good luck.

I do not understand why ALL DEVELOPERS AVOID to make those changes. No website owner wants the visitors to LEAVE the site.

 
Posted : February 4, 2023 06:25
Asaga reacted
Editor
(@editor)
Posts: 553
Honorable Member Admin
 

Keep in mind that the editor body links in ads posted without the change, will NOT open now in a new window.

This works for the new ones or the old ones before you updated to Osclasspoint.

While the extra url field, the change works for old/new urls. No problem.

 
Posted : February 4, 2023 07:17
(@asaga)
Posts: 31
Trusted Member
Topic starter
 

Guys thank you SO MUCH.

 
Posted : February 4, 2023 14:09