svandragt / cuttlefish-blog

Blog app built on Cuttlefish
MIT License
0 stars 0 forks source link

Shortcodes #2

Open svandragt opened 4 years ago

svandragt commented 4 years ago

Content Includes should register a cf:id tag where id is unique to the include. CF adds a way to extract embedded xml content and call the CI matching the CI id, which can then process the xml content. Example:

<?php
$html  = <<<HTML
some paragraph

another paragraph

<cf:nml mode="list" columns="artist,title">content</cf:nml>

<cf:nml mode="view" columns="title">content</cf:nml>

final paragraph.
HTML;

$xml = @simplexml_load_string(sprintf('<xml>%1$s</xml>',$html));

$tag = "cf:nml";
foreach ($xml->$tag as $t) {
  var_dump($t);
}

/*
object(SimpleXMLElement)#4 (2) {
  ["@attributes"]=>
  array(2) {
    ["mode"]=>
    string(4) "list"
    ["columns"]=>
    string(12) "artist,title"
  }
  [0]=>
  string(7) "content"
}
object(SimpleXMLElement)#5 (2) {
  ["@attributes"]=>
  array(2) {
    ["mode"]=>
    string(4) "view"
    ["columns"]=>
    string(5) "title"
  }
  [0]=>
  string(7) "content"
}
*/
svandragt commented 4 years ago

Might call the element “include” with a type attribute. Depends on the cleanest way to register it

svandragt commented 3 years ago

So this is a User Shortcode Register