K
K
Konstantin Spirin2019-07-09 15:35:42
Yii
Konstantin Spirin, 2019-07-09 15:35:42

Unknown Property Error - yii\base\UnknownPropertyException Getting unknown property: frontend\widgets\Share::missbutton?

share.php:

namespace frontend\widgets;
use yii\helpers\Html;

class Share extends ShareWidget {

    public function run() {
        echo Html::beginTag($this->tag , $this->htmlOptions);

    echo str_replace(
      '{button}',
      Html::a(
      '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
   viewBox="0 0 21.9 15.6" enable-background="new 0 0 21.9 15.6" xml:space="preserve" width="21.9" height="20">

</svg>',
      ['/site/share-full', 'url' => urlencode($this->url)],
      [
        //'class' => 'pull-left'
        'onClick' => 'return createModal(this, modalLoadAjax);'
      ]
    ),
      $this->template
    );

    echo str_replace(
      '{button}',
      Html::a(
      '<svg version="1.1" id="Слой_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
   viewBox="0 0 13.1 13.1" enable-background="new 0 0 13.1 13.1" xml:space="preserve" width="20" height="20">

</svg>',
      ['/site/share', 'url' => urlencode($this->url)],
      [
        'class' => 'visible-sm-block visible-xs-block',
        'onClick' => 'return shareWhatsApp(this);'
      ]
    ),
      $this->template
    );
             foreach ($this->networks as $key => $val) {
            echo $this->parseTemplate($key);
        }
   echo Html::endTag($this->tag);
   }
}

ShareWidget.php
namespace frontend\widgets;

use yii\helpers\Url;
use frontend\models\SocialIcons;

class ShareWidget extends \bigpaulie\social\share\Widget {
// public $missbutton;
    protected $networks = [
        //'google-plus' => 'https://plus.google.com/share?url={url}',
        'pinterest' => 'https://pinterest.com/pin/create/button/?url={url}',
        'twitter' => 'https://twitter.com/home?status={url}',
        //'linkedin' => 'https://www.linkedin.com/shareArticle?mini=true&url={url}',
        'facebook' => 'https://www.facebook.com/sharer/sharer.php?u={url}',
    ];

  /*protected $colors = [
        'facebook' => '#3b5998',
    'google-plus' => '#dd4b39',
        'pinterest' => '#cb2027',
        'twitter' => '#55acee',
        'linkedin' => '#007bb6',
  ];*/
  protected $colors = [
        'facebook' => '#9c9c9c',
    'google-plus' => '#9c9c9c',
        'pinterest' => '#9c9c9c',
        'twitter' => '#9c9c9c',
        'linkedin' => '#9c9c9c',
  ];

    protected function parseTemplate($network) {



        if (in_array($network,$this->missbutton)) {
            return false;
        }

        $class = $network;
    $color = $this->colors[$network];

        if ($this->type == 'small') {
            $url = $this->networks[$network];
            $button = str_replace('{button}', '<a href="javascript:;" class="" onClick="sharePopup(\'' . $url . '\');">'
                    . '{network}</a>', $this->template);
            $button = str_replace('{network}', SocialIcons::getIcon($network, $color, 18, 18), $button);
            $button = str_replace('{class}', $class, $button);
            $button = str_replace('{url}', urlencode($this->url), $button);
            return $button;
        } elseif ($this->type == 'large') {
            $url = $this->networks[$network];
            $button = str_replace('{button}', '<a href="javascript:;" class="" onClick="sharePopup(\'' . $url . '\');">'
                    . '{network} {text}</a>', $this->template);
            $button = str_replace('{text}', $this->text, $button);
            $button = str_replace('{network}', SocialIcons::getIcon($network, $color, 30, 30), $button);
            $button = str_replace('{class}', $class, $button);
            $button = str_replace('{url}', urlencode($this->url), $button);
            return $button;
        }
    }

  public function init() {

        if (!$this->id) {
            $this->id = $this->getId();
        }

        if(!isset($this->htmlOptions['id'])){
            $this->htmlOptions['id'] = $this->id;
        }

        if (!$this->url) {
            $this->url = Url::to('', TRUE);
        }
    }
}

5d2489fa30bc3681293658.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Spirin, 2019-07-09
@konst2018

my screenshots for convenience
5d24918b13d36509076520.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question