Post by rempong » Thu Oct 03, 2013 4:56 pm

For wider usage, maybe it need to have custom folder, ex:shortcodes. The program then scan that folder for shortcode function(s). Because if any added shortcode has to put in "shortcodes.php", it will be fat, and not efficent

OPENCART MODULE :
Opencart Compare Link Link your compared product to forum/email

Frontend Link From Admin Dashboard
Get link to product , category, manufacturer, information from admin backend.

Copy and DIRECTLY Edit Product the easy way.

Custom Product Sort Full control to product sorting options

Already Sold Product Module, shows total product sold


Active Member

Posts

Joined
Fri Sep 14, 2012 2:38 pm
Location - Indonesia

Post by rempong » Thu Oct 03, 2013 5:07 pm


OPENCART MODULE :
Opencart Compare Link Link your compared product to forum/email

Frontend Link From Admin Dashboard
Get link to product , category, manufacturer, information from admin backend.

Copy and DIRECTLY Edit Product the easy way.

Custom Product Sort Full control to product sorting options

Already Sold Product Module, shows total product sold


Active Member

Posts

Joined
Fri Sep 14, 2012 2:38 pm
Location - Indonesia

Post by rempong » Thu Oct 03, 2013 5:59 pm

There is some change on manufacturer function, but im not quite certain from what version it started, so i assume from opencart version '1.5.3.1'

Code: Select all

   /**
    * Generate brand/ manufacturer link.
    *
    * [link_brand ssl="0" title="xyz" /]
    * [link_brand ssl="1" title="xyz"]custom text[/link_brand]
    *
    * [link_brand brand="x" ssl="0" title="xyz" /]
    * [link_brand brand="x" ssl="1" title="xyz"]custom text[/link_brand]
    */
   function link_brand($atts, $content = '') {
      extract(shortcode_atts(array(
         'brand'  => 0,
         'ssl'    => 0,
         'title'  => ''
      ), $atts));
      
      $ssl     = ($ssl) ? "'SSL'" : "";
      $title   = ($title) ? 'Title="' . $title . '"' : "";
      
      $this->load->model('catalog/manufacturer');
      $manufacturer = $this->model_catalog_manufacturer->getManufacturer($brand);
      
      if ($manufacturer) {
        //version check
        $suffix = 'info';
        if (version_compare(VERSION, '1.5.3.1', '<=') == true) {
           $suffix ='product'; 
        }
                
         if (!$content) {
            $this->load->language('product/manufacturer');
            
            if (!$brand) {
               return '<a href="' . $this->url->link('product/manufacturer', '', $ssl) . '" ' . $title . '>' . $this->language->get('text_brand') . '</a>';
            } else {
               return '<a href="' . $this->url->link('product/manufacturer/'.$suffix, 'manufacturer_id=' . $brand, $ssl) . '" ' . $title . '>' . $manufacturer['name'] . '</a>';
            }
         } elseif ($content) {
            if (!$brand) {
               return '<a href="' . $this->url->link('product/manufacturer', 'manufacturer_id=' . $brand, $ssl) . '" ' . $title . '>' . $content . '</a>';
            } else {
               return '<a href="' . $this->url->link('product/manufacturer/'.$suffix, 'manufacturer_id=' . $brand, $ssl) . '" ' . $title . '>' . $content . '</a>';
            }
         }
      } elseif (!$manufacturer && $content) {
         return $content;
      }
   }

OPENCART MODULE :
Opencart Compare Link Link your compared product to forum/email

Frontend Link From Admin Dashboard
Get link to product , category, manufacturer, information from admin backend.

Copy and DIRECTLY Edit Product the easy way.

Custom Product Sort Full control to product sorting options

Already Sold Product Module, shows total product sold


Active Member

Posts

Joined
Fri Sep 14, 2012 2:38 pm
Location - Indonesia

Post by rempong » Thu Oct 03, 2013 6:35 pm

Embed image :

Code: Select all

/**
     * Embed Image 
     * @example [img title="helllo world" width=100 height=200]http://example.com/cool_image.jpg[/img]
     **/
    function img( $atts , $content = null ) {
    
    	// Attributes
    	extract( shortcode_atts(
    		array(
    			'width' => '',
    			'height' => '',
                'title' => '',
    		), $atts )
    	);
    
    	// Code
    	return '<img src="' . $content . '" width="' . $width . '" height="' . $height . '" alt="'.$title.'" title="'.$title.'">';
    }

OPENCART MODULE :
Opencart Compare Link Link your compared product to forum/email

Frontend Link From Admin Dashboard
Get link to product , category, manufacturer, information from admin backend.

Copy and DIRECTLY Edit Product the easy way.

Custom Product Sort Full control to product sorting options

Already Sold Product Module, shows total product sold


Active Member

Posts

Joined
Fri Sep 14, 2012 2:38 pm
Location - Indonesia

Post by qahar » Fri Oct 04, 2013 11:20 pm

rempong wrote:For wider usage, maybe it need to have custom folder, ex:shortcodes. The program then scan that folder for shortcode function(s). Because if any added shortcode has to put in "shortcodes.php", it will be fat, and not efficent
For themes, we can create folder include/ then use include_once() inside shortcodes.php
But for extensions, I'm not decide the final approach. One of the plan is to to use catalog/shortcodes/ folder to populate shortcodes for extensions.

One thing I can sure is the sequent of shortcode is default, extensions then themes. Themes will able to overwrite default and extensions shortcodes.

Will check the manufacturer link and add the image to default shortcodes

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by qahar » Sat Oct 05, 2013 10:11 pm

Update to v.1.0-rc.3

* Fixed
^ Improvements
+ New Feature
~ Deprecated

v.1.0-RC.3
^ Rewrite shortcodes API to OO approach
^ Move default shortcodes from library to helper
^ Strip shortcode on user input: review, shipping n payment comment and return details
+ Image shortcodes
+ Global shortcode folder for extensions shortcodes

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by qahar » Fri Oct 18, 2013 9:30 pm

Stable version 1.0 released.

Further info: http://qahar.github.io/opencart-shortcodes/

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by butte » Sat Oct 19, 2013 4:27 am

Since it went by above and there's been shift in usages generally . . . include once or require once?

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am

Post by qahar » Sat Oct 19, 2013 3:55 pm

butte wrote:Since it went by above and there's been shift in usages generally . . . include once or require once?
Actually I'm not really understand your question.
I'm expecting an error when require is fail to include the file.

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by butte » Sat Oct 19, 2013 11:29 pm

Good link. I've understood the shift in prevailing usage from include (or with once) to require (or with once) to spring from some basic concerns, and meanwhile noticed that include (or with once) seems in OC itself to have vanished in favor of require (or with once). Thus, the question.

In the link #45 speaks to that. "My suggestion is to just use require_once 99.9% of the time." In the note below there, "The key points are that the include family are usually an outright bad idea (because it's pretty rare to be including files that have any possibility of not existing), and that out of require_once and require, you should use require_once when including files that define functions or classes to be used elsewhere, or instantiate singletons like database connection objects, and use require for including files that immediately do stuff when they get included. In any large web application, the latter kind of include is unusual."

Practicalities are few, essentially just variants along these lines. At #3, "With require the file must exist, if it doesn't then an error will display; whereas with include - if the file doesn't exist then then the page will continue loading." At #2, "Use require_once to load dependencies (classes, functions, constants). Use require to load template-like files."

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am

Post by qahar » Wed Nov 20, 2013 8:17 am

Update to v1.1-rc

* Fixed
^ Improvements
+ New Feature
~ Deprecated

v1.1-rc
^ Image shortcode: image cache
^ Login shortcode: group restriction
+ Image modalbox shortcode
+ Multi-language

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by qahar » Fri Nov 29, 2013 12:18 am

Update release v1.1

Changelog same as v.1.1, just mark it as stable.

Update to v1.1.1
* Fixed
^ Improvements
+ New Feature
~ Deprecated

v1.1.1
* Fix OpenCart Shortcodes issue on SEO Url activated.

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by musicincloud » Sun May 04, 2014 6:22 pm

Hello ! extension looks really great !
i just installed it and unfortunatly i got this error :

Fatal error: Call to a member function do_shortcode() on a non-object in /home/dorba468/public_html/opencart/vqmod/vqcache/vq2-system_engine_controller.php on line 124

i guess it's because i'm using seo mega pack pro, since i saw in the vqmod file it's looking for something in seo_url...
i should change something in the xml file ?
any ideas ???? thanks !

www.musicincloud.com - Royalty Free Music
www.lapalinka.com - Gypsy Jazz


New member

Posts

Joined
Sat Mar 22, 2014 11:07 am

Post by qahar » Mon May 05, 2014 9:48 am

I use common/seo_url.php to put Shortcodes into OpenCart registry and load default shortcodes etc.

From the error I can say that the $this->shortcodes not available at OpenCart registry.
And this happen (most possibly) because seo mega pack force opencart not to load common/seo_url.php and use their own seo file.

I suggest you to copy part of Shortcodes xml into seo mega pack.
Since I don't have seo mega pack, I cannot suggest what file you need to modificate or where you need to put them.

I hope you get the idea why it's not work

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by dunks » Sat Jun 14, 2014 11:46 pm

Thanks Qahar, this is useful.. i can create many category link on product :D custom link is very useful :)

Ingat Gadget, Ingat DroidLime https://www.droidlime.com/


User avatar
Active Member

Posts

Joined
Wed Apr 20, 2011 1:19 pm
Location - Jakarta - Indonesia

Post by qahar » Mon Apr 27, 2015 11:26 pm

Bump for Shortcodes v2.0.0 release!

Read first thread for more information.

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by IP_CAM » Tue May 05, 2015 8:13 am

Well Done, it helps Newbie's as well as anyone else, to get a certain 'overview' on how it's done, behind the curtain!
Super!
Ernie
can be seen here:
http://www.bigmax.ch/shop/index.php?rou ... ation_id=8

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by qahar » Tue May 05, 2015 5:13 pm

Actually there is demo link in first thread but thanks IP CAM
I hope more people can use shortcodes ;D

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by daniil_oc » Mon May 11, 2015 9:24 pm

Hello!

I'd like to know if I can embed information page content instead of link.

For example, I used this code to insert text from one page into all product descriptions.

Code: Select all

// TODO:Add page text
// $this->load->model('catalog/information');
// $information_info = $this->model_catalog_information->getInformation(20);
// $infotext = html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8');
// ?>
// <?php // echo $infotext; ?>
And I want to add variable shortcode (i.e {page=20}) so that I could insert variable text in dif. products.

Will it be possible someday?

Newbie

Posts

Joined
Mon Aug 19, 2013 4:05 am

Post by qahar » Tue May 12, 2015 12:36 am

The idea of default shortcodes is to give you example on how to use and develope shortcodes tags.
Because OpenCart shortcodes is a "plugin" to help developer to provide Shortcodes for end user.

You can create your own shortcodes tags, for complete refference read the Shortcodes Developer Guide.

For the quick, create file shortcodes_custom.php and put it at catalog/view/theme/your_active_theme/

The content of the file

Code: Select all

class ShortcodesCustom extends Controller {
  function info_content($atts) {
    extract($this->shortcodes->shortcode_atts(array(
       'id' => '',
    ), $atts));

    if ($id) {
      $this->load->model('catalog/information');
      $information_info = $this->model_catalog_information->getInformation($id);
      $infotext = html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8');
      
      return $infotext;
    }
  }
}
To use just add the shortcode tags to your content

Code: Select all

[info_content id="20" /]

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia
Who is online

Users browsing this forum: No registered users and 51 guests