0

I've added a field called icons of type svg-icons and am able to select icons I've added without an issue. I am having trouble outputting them on the front end however. I get twig errors no matter what I try.

Have done {{ dump(entry.icons) }} and get the following output where you can see 11 lines from the bottom the path and name of the select svg icon.

How do I output that to the template?

D:\path\to\craft\app\vendor\twig\twig\lib\Twig\Extension\Debug.php:56:
object(Craft\SvgIconsModel)[700]
  protected 'classSuffix' => string 'Model' (length=5)
  protected 'strictAttributes' => boolean true
  private '_classHandle' (Craft\BaseModel) => null
  private '_attributeConfigs' (Craft\BaseModel) => 
    array (size=6)
      'icon' => 
        array (size=2)
          'default' => null
          'type' => string 'string' (length=6)
      'sprite' => 
        array (size=2)
          'default' => null
          'type' => string 'string' (length=6)
      'type' => 
        array (size=2)
          'default' => null
          'type' => string 'string' (length=6)
      'resource' => 
        array (size=2)
          'default' => null
          'type' => string 'string' (length=6)
      'width' => 
        array (size=9)
          'maxLength' => int 11
          'min' => float -2147483648
          'max' => float 2147483647
          'decimals' => int 0
          'default' => null
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 11
          'column' => string 'integer' (length=7)
      'height' => 
        array (size=9)
          'maxLength' => int 11
          'min' => float -2147483648
          'max' => float 2147483647
          'decimals' => int 0
          'default' => null
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 11
          'column' => string 'integer' (length=7)
  private '_attributes' (Craft\BaseModel) => 
    array (size=3)
      'icon' => string 'general\design.svg' (length=18)
      'width' => float 512
      'height' => float 512
  private '_extraAttributeNames' (Craft\BaseModel) => null
  private '_errors' (CModel) => 
    array (size=0)
      empty
  private '_validators' (CModel) => null
  private '_scenario' (CModel) => string '' (length=0)
  private '_e' (CComponent) => null
  private '_m' (CComponent) => null
  • 1
    Have you tried {{ entry.icons.icon }}? – Stephen Lewis Apr 22 '17 at 20:53
1

Never used the plugin before, but from glancing at their docs, it looks like entry.icons.icon is what you're looking for.

Any other properties on their SvgIconsModel should work as well.

  • Oh, I see how it is, Brad. – Stephen Lewis Apr 23 '17 at 0:34
  • @StephenLewis I can't help it you have issues committing. – Brad Bell Apr 23 '17 at 0:53
  • Brad Bell, Chief Officer of Community Knowledge. – Stephen Lewis Apr 23 '17 at 1:09
  • That works, but I still don't see where it says that in the docs. I would've expected the docs to specifically say something like {{ entry.fieldname.icons }} – CreateSean Apr 23 '17 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.