Jump to content

ukyo

Members
  • Posts

    248
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by ukyo

  1. Added pull request for this issue : #14 If you want, you can apply my changes to your files or you can directly download applied version. I added 2 option for FieldtypeMapMarker module settings, api key and url parameters.
  2. I found the problem, when i add a <base> tag inside <head> tag, this problem appear.
  3. Created form by FormBuilder and PadLoper, i have problem when i make post. For example, if i have a contact form at www.domanin.ltd/contact/ url and if want to make post form redirecting me to homepage (www.domanin.ltd). All my post data going to homepage but there is not a process for this form. same result for PadLoper forms. Basically processwire backend form creations not working well for me in front-end. There is a problem with url "./". If i change url with str_replace function PadLoper checkout form working. echo str_replace('./', $page->httpUrl, $checkout->render()); Some one has this problem ? Question & Answers about problem: @ukyo(question) If i use Option C Embed method. When i submit form page redirecting to (making form post) homepage from contact page. How can i hack this ? I want to make post current called page. I added this option on my settings but need tips about how to ? @ryan(answer) Since you are using embed C, make sure that any pages you put forms on don't have the trailing slash removed. FormBuilder sticks to PW's default setting for trailing slashes. If you've changed the slash setting for a template that outputs a form (embed C only) that could interfere with the form submission. @ukyo(answer) I didn't changed slash settings, and after your answer i checked slash settings and everything look like normal. For be sure unchecked this option and tested, didd't work. Checked this option again and tested, didn't work. Also i have same problem with PadLoper module (using same method). Do i have problem with my pw setups or settings ? or do i need to enable some php server side settings ? Please, let me know ProcessWire 3.0.20 devns PHP 5.6.10 OS X El Capitan
  4. This module extends WireMail base class, integrating the PHPMailer mailing library into ProcessWire. Module Directory - Githup repo
  5. With 0.9.8 version problem look like gone. Thanks for quick reply / fix !
  6. After update to version 0.9.7 i have this error : Fatal error: Call to a member function getImageInfo() on a non-object in /......./......./......./......./site/assets/cache/FileCompiler/site/modules/TracyDebugger/ProcesswireInfoPanel.inc on line 259 Tracy panel not appear for front-end and if i comment this line it look like working. PW version : ProcessWire 3.0.9 devns
  7. Your array look like have auto index. Try to set array key as $value->id if there is a id or something like it. on here: $field->addOption($option->value, $option->title); you used $option->value like a key but on here : $valArray[] .= $value->title; you don't have a key ? and when you set an array don't use .= this will be enought $valArray[] = $value->title; or $valArray[$value->value] = $value->title; For asmSelect you can clone core asmSelect module and rename it modify module as your needs or if there hook available you can make hook or you can use asmSelect directly.
  8. It for uikit lightbox component, resizing image and adding lightbox link automatically with overlay effect. If you don't use uikit you can remove these codes from function or you can customize them for your needs. I dind't modify my code, directly shared them with community and you can take it as example and you can modify codes or you can create a function as your needs. // Without lightbox $img = image($page->image->first(), $config->respImgOptions['villa']['list']); // With lightbox, its enought to send "true" or "overlay" class, after set responsive image settings $img = image($page->image->first(), $config->respImgOptions['villa']['list'], true); Lightbox example output : <figure class='uk-overlay uk-overlay-hover'> <picture> <!--[if IE 9]> <video style='display: none;'> <![endif]--> <source srcset='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-srcset='/site/assets/files/1058/terra-nova-003.344x212.jpg' media='(max-width: 479px)' /> <source srcset='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-srcset='/site/assets/files/1058/terra-nova-003.309x190.jpg' media='(max-width: 767px)' /> <source srcset='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-srcset='/site/assets/files/1058/terra-nova-003.265x164.jpg' media='(max-width: 959px)' /> <!--[if IE 9]> </video> <![endif]--> <img src='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-srcset='/site/assets/files/1058/terra-nova-003.290x180.jpg' alt='terra-nova-003' class="lazyload uk-responsive-width uk-overlay-spin" /> </picture> <div class='uk-overlay-panel uk-overlay-background uk-overlay-fade'></div> <div class='uk-overlay-panel uk-overlay-icon uk-overlay-fade'></div> <a class='uk-position-cover' href='/site/assets/files/1058/terra-nova-003.jpg' title='Terra Nova' data-uk-lightbox="{group:'terra-nova'}"> <span class='uk-hidden'>Terra Nova</span> </a> </figure>
  9. Thanks @horst, if you see my mistakes and no need things or any useful things let me know please
  10. sorry also i updated my first reply /** * Generate Attributes Array or String * * @param $item * @return string */ function buildAttrs($item) { $attributes = ""; // echo "<pre>Key : " . print_r($item, true) . "</pre>"; if(array_key_exists('attributes', $item) && is_array($item['attributes'])) { foreach($item['attributes'] as $key => $attr) { $attributes .= ' ' . $key . '="' . $attr . '"'; } } return $attributes; } /** * * @param $image * @param $key * @param $options * @return string */ function buildSrcAndSrcset($image, $key, $options) { $return = ''; // echo "<pre>Key : {$key}, " . print_r($options, true) . "</pre>"; if(!empty($options[$key]) && !empty($options[$key]['sets']) && is_array($options[$key]['sets'])) { $x=1; $countSets = count($options[$key]['sets']); $sets = ""; foreach($options[$key]['sets'] as $k => $rules) { $y=$x++; $separator = ($y != $countSets) ? ", " : ""; if(!is_array($rules) && $rules == 'original') { $static_url = static_url($image->url); $sets .= "{$static_url} {$key}w{$separator}"; } elseif(isset($rules['width']) || isset($rules['height'])) { $size = imageResize($image, $rules); if(!is_null($size)) { $sets .= "{$size['url']} {$size['width']}w{$separator}"; } } } if($sets != "") $return = " {$key}='{$sets}'"; } elseif(!empty($options[$key]) && !empty($options[$key]['method']) && is_array($options[$key]['method'])) { $img = imageResize($image, $options[$key]['method']); if(!is_null($img)) $return = " {$key}='{$img['url']}'"; } elseif(!empty($options[$key]) && is_string($options[$key])) { $return = " {$key}='{$options[$key]}'"; } return $return; }
  11. On my side i prepared a function for srcset and <picture> tag creation. Function output look like : <picture> <!--[if IE 9]> <video style='display: none;'> <![endif]--> <source srcset='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-srcset='/site/assets/files/1058/terra-nova-001.404x270.jpg' media='(max-width: 479px)' /> <source srcset='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-srcset='/site/assets/files/1058/terra-nova-001.692x462.jpg' media='(max-width: 767px)' /> <source srcset='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-srcset='/site/assets/files/1058/terra-nova-001.427x285.jpg' media='(max-width: 959px)' /> <!--[if IE 9]> </video> <![endif]--> <img src='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-srcset='/site/assets/files/1058/terra-nova-001.630x421.jpg' alt='terra-nova-001' class="lazyload uk-width-1-1" /> </picture> Here are my functions : /** /** * Generate Attributes Array or String * * @param $item * @return string */ function buildAttrs($item) { $attributes = ""; // echo "<pre>Key : " . print_r($item, true) . "</pre>"; if(array_key_exists('attributes', $item) && is_array($item['attributes'])) { foreach($item['attributes'] as $key => $attr) { $attributes .= ' ' . $key . '="' . $attr . '"'; } } return $attributes; } /** * * @param $image * @param $key * @param $options * @return string */ function buildSrcAndSrcset($image, $key, $options) { $return = ''; // echo "<pre>Key : {$key}, " . print_r($options, true) . "</pre>"; if(!empty($options[$key]) && !empty($options[$key]['sets']) && is_array($options[$key]['sets'])) { $x=1; $countSets = count($options[$key]['sets']); $sets = ""; foreach($options[$key]['sets'] as $k => $rules) { $y=$x++; $separator = ($y != $countSets) ? ", " : ""; if(!is_array($rules) && $rules == 'original') { $static_url = static_url($image->url); $sets .= "{$static_url} {$key}w{$separator}"; } elseif(isset($rules['width']) || isset($rules['height'])) { $size = imageResize($image, $rules); if(!is_null($size)) { $sets .= "{$size['url']} {$size['width']}w{$separator}"; } } } if($sets != "") $return = " {$key}='{$sets}'"; } elseif(!empty($options[$key]) && !empty($options[$key]['method']) && is_array($options[$key]['method'])) { $img = imageResize($image, $options[$key]['method']); if(!is_null($img)) $return = " {$key}='{$img['url']}'"; } elseif(!empty($options[$key]) && is_string($options[$key])) { $return = " {$key}='{$options[$key]}'"; } return $return; } /** * Image : Create <img /> tag with attributes and responsive lazyload option * * @param $image * @param array $options * @return string */ function image($image, $options = array(), $lightbox=FALSE) { $return = ""; // Alt attribute $alt = ($image->description != '') ? $image->description : pathinfo($image->filename, PATHINFO_FILENAME); $alt = " alt='{$alt}'"; if(array_key_exists('picture', $options) && is_array($options['picture'])) { $picture = $options['picture']; // Set Attributes $attributes = ""; if(array_key_exists('attributes', $picture)) { $attributes = buildAttributes($picture['attributes']); } $return .= "\n<picture{$attributes}>"; if(array_key_exists('source', $options['picture']) && is_array($options['picture']['source'])) { $return .= "\n\t<!--[if IE 9]><video style='display: none;'><![endif]-->"; $sources = $options['picture']['source']; foreach($sources as $key => $source) { $attrSrc = buildSrcAndSrcset($image, 'src', $source); $attrSrcset = buildSrcAndSrcset($image, 'srcset', $source); $attrDataSrcset = buildSrcAndSrcset($image, 'data-srcset', $source); $attributes = buildAttrs($source); $attrMedia = " media='{$key}'"; $return .= "\n\t\t<source{$attrSrc}{$attrSrcset}{$attrDataSrcset}{$attributes}{$attrMedia} />"; } $return .= "\n\t<!--[if IE 9]></video><![endif]-->"; } if(array_key_exists('img', $options['picture']) && is_array($options['picture']['img'])) { $img = $options['picture']['img']; $attrSrc = buildSrcAndSrcset($image, 'src', $img); $attrSrcset = buildSrcAndSrcset($image, 'srcset', $img); $attrDataSrcset = buildSrcAndSrcset($image, 'data-srcset', $img); $attributes = buildAttrs($img); $return .= "\n\t<img{$attrSrc}{$attrSrcset}{$attrDataSrcset}{$alt}{$attributes} />"; } $return .= "\n</picture>"; } elseif(array_key_exists('img', $options) && is_array($options['img'])) { $img = $options['img']; $attrSrc = buildSrcAndSrcset($image, 'src', $img); $attrSrcset = buildSrcAndSrcset($image, 'srcset', $img); $attrDataSrcset = buildSrcAndSrcset($image, 'data-srcset', $img); $attributes = buildAttrs($img); $return .= "\n<img{$attrSrc}{$attrSrcset}{$attrDataSrcset}{$alt}{$attributes} />"; } else { $src = " src='" . static_url($image->url) . "'"; $width = " width='{$image->width}'"; $height = " height='{$image->height}'"; // Set Attributes $attributes = ""; if(array_key_exists('attributes', $options)) { $attributes = buildAttributes($options['attributes']); } $return .= "\n<img{$src}{$width}{$height}{$alt}{$attributes} />"; } if(isset($lightbox) && $lightbox != FALSE) { $page = wire('page'); $title = ($image->description != "") ? $image->description : $page->title; $overlayEffect = (!is_bool($lightbox) && $lightbox != '') ? " " . $lightbox : " uk-overlay-fade"; $return = "\n<figure class='uk-overlay uk-overlay-hover'> \n\t{$return} \n\t<div class='uk-overlay-panel uk-overlay-background{$overlayEffect}'></div> \n\t<div class='uk-overlay-panel uk-overlay-icon{$overlayEffect}'></div> \n\t<a class='uk-position-cover' href='{$image->url}' title='{$title}' data-uk-lightbox=\"{group:'{$page->name}'}\"><span class='uk-hidden'>{$title}</span></a> \n</figure>"; } return $return; } /** * Resize Image * * @param $image * @param array $method * @return array|null */ function imageResize($image, $method=array()) { $alt = ($image->description != '') ? $image->description : pathinfo($image->filename, PATHINFO_FILENAME); if(isset($method['type']) && isset($method['width']) || isset($method['height'])) { // Set Resize Options if(isset($method['options'])) $options = $method['options']; else $options = wire('config')->imageSizerOptions; if($method['type'] === 'size' && isset($method['width']) && isset($method['height'])) { $size = $image->size($method['width'], $method['height'], $options); } elseif($method['type'] === 'width' && isset($method['width'])) { $size = $image->width($method['width'], $options); } elseif($method['type'] === 'height' && isset($method['height'])) { $size = $image->height($method['height'], $options); } else { $size = null; } if(!is_null($size)) { return array( 'url' => static_url($size->url), 'width' => $size->width, 'height' => $size->height, 'alt' => $alt ); } } elseif(is_null($method)) { return array( 'url' => static_url($image->url), 'width' => $image->width, 'height' => $image->height, 'alt' => $alt ); } return null; } /** * Return url with static url * * @param string $url * @return string */ function static_url($url="") { $config = wire('config'); if($config->debug === false && isset($config->static_url) && $config->static_url != "") { $static_url = $config->static_url; } else { $static_url = ""; } return $static_url . $url; } I set responsive sizes on my config file : /** * Responsive Image Options */ $responsiveSizes = array( 'small' => '480', 'medium' => '768', 'large' => '960', 'xlarge' => '1220' ); $config->resSmall = "(max-width: " . ($responsiveSizes['small']-1) . "px)"; $config->resMedium = "(max-width: " . ($responsiveSizes['medium']-1) . "px)"; $config->resLarge = "(max-width: " . ($responsiveSizes['large']-1) . "px)"; $config->resXlarge = "(min-width: {$responsiveSizes['xlarge']}px)"; And I created a file (including this file inside my init.php file) that file have responsive image sizes like : /** * Template --Villa List-- */ $respImgOptions['villa']['list'] = array( 'picture' => array( 'source' => array( $config->resSmall => array( 'srcset' => 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', 'data-srcset' => array( 'method' => array( 'type' => 'size', 'width' => 404, 'height' => 270 ) ) ), $config->resMedium => array( 'srcset' => 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', 'data-srcset' => array( 'method' => array( 'type' => 'size', 'width' => 692, 'height' => 462 ) ) ), $config->resLarge => array( 'srcset' => 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', 'data-srcset' => array( 'method' => array( 'type' => 'size', 'width' => 427, 'height' => 285 ) ) ) ), 'img' => array( 'src' => 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', 'attributes' => array( 'class' => 'lazyload uk-width-1-1' ), 'data-srcset' => array( 'method' => array( 'type' => 'size', 'width' => 630, 'height' => 421 ) ) ) ) ); And after all done calling images from page like : // on here you need to send single PageImage ! $img = image($page->image->first(), $config->respImgOptions['villa']['list']); Like this usage if you have https://github.com/aFarkas/lazysizes and https://github.com/aFarkas/lazysizes/tree/gh-pages/plugins/respimg every thing will work well !
  12. Like @LostKobrakai example. Also you can check full tags usage from here : http://ogp.me/
  13. Updated module Added all html tags, for code completion. Its only work with static calls. Separated all classes HTML Element Reference
  14. SIX AND ONE => ALTI VE BIR => https://en.wikipedia.org/wiki/Trabzon_Province (I was born here) Vehicle registration code is : 61 and my company name. Living here : https://en.wikipedia.org/wiki/Marmaris since 1988
  15. For tag function not supporting $attributes variable. I disabled this and added attr(), data() short functions to class. For make readable view now you can use attr(), data(), addClass() and id() functions. For add multiple attributes and dataAttributes (i am not using these functions much) you can use attributes() and dataAttributes() functions. For make clear and understandable code here is an example : html::div() ->addClass('container') ->addClass('container-center') ->attr('style', 'border: 1px solid #000;') ->data('id', $page->id) ->data('title', $page->title) ->child( html::h1($page->title) ->addClass('h1-title') ->r() ) ->child( html::div($page->body) ->addClass('container-inner') ->r() ) ->o($config->debug); <!-- Output <div class="container container-center" style="border: 1px solid #000;" data-id="Page id field data will come here" data-title="Page title field data will come here"> <h1 class="h1-title"> Page title field data will come here </h1> <div class="container-inner"> Page body field data will come here </div> </div> -->
  16. Updated module with a magic method. Now you can pass element name directly to class. Some Examples : // Working With ProcessWire $ul = html::ul()->addClass('list'); foreach($page->children as $p) { $ul->child( html::li() ->addClass('list-item') ->data('id', $p->id) ->child( html::a($p->title) ->addClass('list-item-link') ->attr('href', $p->url) ->data('id', $p->id)->r() )->r() ); } $ul->o(true); /* output : <ul class='list'> <li class='list-item' data-id='1057'> <a class='list-item-link' href='/en/villas/' data-id='1057'> Villas </a> </li> <li class='list-item' data-id='1001'> <a class='list-item-link' href='/en/location/' data-id='1001'> Location </a> </li> <li class='list-item' data-id='1090'> <a class='list-item-link' href='/en/guestbook/' data-id='1090'> Guestbook </a> </li> <li class='list-item' data-id='1055'> <a class='list-item-link' href='/en/contact/' data-id='1055'> Contact </a> </li> <li class='list-item' data-id='1005'> <a class='list-item-link' href='/en/site-map/' data-id='1005'> Site Map </a> </li> </ul> */ html::div("Hey !") ->addClass('container') ->addClass('container-center') ->id('centered-container') ->output(true); /* output :: <div id='centered-container' class='container container-center'> Hey ! </div> */ html::ul()->addClass('list')->children(array( html::li('Li element value 1')->addClass('list-item')->r(), html::li('Li element value 2')->addClass('list-item')->r(), html::li('Li element value 3')->addClass('list-item')->r(), html::li('Li element value 4')->addClass('list-item')->r(), html::li('Li element value 5')->addClass('list-item')->r() ))->o(true); /* output :: <ul class='list'> <li class='list-item'> Li element value 1 </li> <li class='list-item'> Li element value 2 </li> <li class='list-item'> Li element value 3 </li> <li class='list-item'> Li element value 4 </li> <li class='list-item'> Li element value 5 </li> </ul> */ html::hr(null, "/>")->o(); /* output : <hr /> */
  17. You can use it @Macrura example, but firstly check is there a image and don't use foreach ! if($item->images->count > 0) $out .= "<img src='{$item->images->first()->url}' />";
  18. Now it is a module ! You can continue topic from : https://processwire.com/talk/topic/11761-avbmarkuphtml/
  19. AvbMarkupHtml - HTML tag manager for ProcessWire This module allow you to use less HTML elements inside your PHP code ! Added hook for page. For make quick markup calls : $page->html(); Github : https://github.com/trk/AvbMarkupHtml Example usage and all methods : // All Configs $config = array( 'quote' => '"', 'indent_with' => ' ', 'tags_without_indentation' => 'link,img,meta', 'WirePage' => null, 'tag' => null, 'tagSelfClosed' => null, 'tagNoClose' => null, 'tagCustom' => null, 'tagStart' => '', 'tagEnd' => '', 'prepend' => '', 'prepends' => '', 'attributes' => array(), 'dataAttributes' => array(), 'label' => '', 'note' => '', 'text' => '', 'texts' => array(), 'hasTexts' => false, 'field' => '', 'field_value' => '', 'fields' => array(), 'hasFields' => false, 'child' => '', 'children' => '', 'append' => '', 'appends' => '' ); // All Methods $page->html(array('key', 'value')) // $config ->tag('string', $args=array())) // tag name, $args=content,tag-options => "/>" self closed, "->" no close, "=>" special tag ->setQuote('double or single quote') // default is : " ->addClass('string') // Element class name ->id('string') // Element id ->attr('key', 'value') // output : key='value' ->attributes(array('key', 'value')) // attributes ->data('key', 'value') // output : data-key='value' ->dataAttributes(array('key', 'value')) // data-attributes, this will add auto data- prefix to your attribute ->prepend('string') // a string value ->prepends(array('values')) // array for values ->text('string') // text for inner tag ->field('field_name', 'page_object') // Field name and page object ->texts(array()) // enter text array | array('Text 1', 'Text 2') ->fields(array(), 'page_object') // enter field names as array, a page | array('title', 'body') ->note('field_name', 'page') // enter a field name, a page ->label('field_name', 'page') // enter a field name, a page ->append('string') // a string value ->appends(array('values')) // array for values ->r(true|false) // Alis with ->render(); function ->render(true|false) // This will return result ->o(true|false) // Alias with ->output(); function ->output(true|false); // This will print result | default pretty print value is : false // #Example 1 : Working With ProcessWire $ul = html::ul()->addClass('list'); foreach($page->children as $p) { $ul->child( html::li() ->addClass('list-item') ->data('id', $p->id) ->child( html::a($p->title) ->addClass('list-item-link') ->attr('href', $p->url) ->data('id', $p->id)->r() )->r() ); } $ul->o(true); /* output : <ul class='list'> <li class='list-item' data-id='1057'> <a class='list-item-link' href='/en/villas/' data-id='1057'> Villas </a> </li> <li class='list-item' data-id='1001'> <a class='list-item-link' href='/en/location/' data-id='1001'> Location </a> </li> <li class='list-item' data-id='1090'> <a class='list-item-link' href='/en/guestbook/' data-id='1090'> Guestbook </a> </li> <li class='list-item' data-id='1055'> <a class='list-item-link' href='/en/contact/' data-id='1055'> Contact </a> </li> <li class='list-item' data-id='1005'> <a class='list-item-link' href='/en/site-map/' data-id='1005'> Site Map </a> </li> </ul> */ // #Example 2 html::div() ->addClass('container') ->addClass('container-center') ->attr('style', 'border: 1px solid #000;') ->data('id', $page->id) ->data('title', $page->title) ->child( html::h1($page->title) ->addClass('h1-title') ->r() ) ->child( html::div($page->body) ->addClass('container-inner') ->r() ) ->o($config->debug); /* Output <div class="container container-center" style="border: 1px solid #000;" data-id="Page id field data will come here" data-title="Page title field data will come here"> <h1 class="h1-title"> Page title field data will come here </h1> <div class="container-inner"> Page body field data will come here </div> </div> */ // #Example 3 : html::div("Hey !") ->addClass('container') ->addClass('container-center') ->id('centered-container') ->output(true); /* Output <div id='centered-container' class='container container-center'> Hey ! </div> */ // #Example 4 html::ul()->addClass('list')->children(array( html::li('Li element value 1')->addClass('list-item')->render(), html::li('Li element value 2')->addClass('list-item')->render(), html::li('Li element value 3')->addClass('list-item')->render(), html::li('Li element value 4')->addClass('list-item')->render(), html::li('Li element value 5')->addClass('list-item')->render() ))->output(true); /* Output <ul class='list'> <li class='list-item'> Li element value 1 </li> <li class='list-item'> Li element value 2 </li> <li class='list-item'> Li element value 3 </li> <li class='list-item'> Li element value 4 </li> <li class='list-item'> Li element value 5 </li> </ul> */ // #Example 5 $title = $page->html('title')->tag('h1')->addClass('h1-class')->render(); echo $title; // #Example 6 : This will directly print $page->html($page->title)->tag('h1')->addClass('h1-class')->output(); html::h1($page->title)->o(); // #Example 7 : Self Closed Tag $modules->AvbMarkupHtml->html()->tag('hr', array(null, '/>'))->output(); html::hr()->o(); // #Example 8 $page->html($page->title)->tag('h1')->addClass('my-h1-class')->output(); html::h1($page->title)->addClass('my-h1-class')->o(); // #Example 9 $page->html('title', $pages->get('/contact/'))->tag('h1')->addClass('my-h1-class')->output(); html::h1()->addClass('my-h1-class')->field('title', $pages->get('/contact/'))->o(); // #Example 10 $modules->AvbMarkupHtml->html()->tag('div')->addClass('container')->children(array( $page->html('title')->tag('h1')->addClass('my-title')->render(), $page->html('body')->tag('div')->addClass('my-body')->render() ))->output(); // #Example 11 | Multiple child, prepend, append $html = $page->html()->tag('div')->addClass('uk-container')->addClass('uk-container-center'); $html->prepend( $page->html()->tag('div')->text('Prepend #1 !')->render() ); $html->prepend( $page->html()->tag('div')->text('Prepend #2 !')->render() ); $html->child( $page->html()->tag('div')->text('Hey !')->render() ); $html->child( $page->html()->tag('div')->text('Foo !')->render() ); $html->child( $page->html()->tag('div')->text('Bar !')->render() ); $html->append( $page->html()->tag('div')->text('Append #1 !')->render() ); $html->append( $page->html()->tag('div')->text('Append #2 !')->render() ); $html->output(); // #Example 12 | Create A HTML page //-> Create Html Tag $html = $page->html()->tag('html')->attr('lang', 'en')->attr('dir', 'ltr'); //-> Create Head Tag $head = $page->html()->tag('head'); //-> Add TITLE inside HEAD tag $head->child( $page->html()->tag('title')->text('My Website')->render() ); //-> Put HEAD inside HTML Tag $html->child($head->render()); //-> Create BODY Tag $body = $page->html()->tag('body')->addClass($page->template); //-> Create DIV Tag $container = $page->html()->tag('div')->addClass('container'); $container->children(array( $page->html()->tag('h1')->addClass('h1-title')->text('H1 Title')->render(), $page->html()->tag('div')->addClass('body-content')->text('Body Content')->render() )); //-> Put DIV.container inside BODY Tag $body->child($container->render()); //-> Put BODY inside HTML Tag $html->child($body->render()); $html->output(true); // Pretty HTML output /* Output <html lang='en' dir='ltr'> <head> <title> My Website </title> </head> <body class='homepage'> <div class='container'> <h1 class='h1-title'> H1 Title </h1> <div class='body-content'> Body Content </div> </div> </body> </html> */ // #Example 13 Static Call Example $article = html::tag('article')->addClass('uk-article')->children(array( html::field('title')->tag('h1')->addClass('uk-article-title')->render(), html::tag('hr', array(null, '/>'))->addClass('uk-article-divider')->render(), html::field('body')->render() )); $article->output(true); /* Output <article class='uk-article'> <h1 class='uk-article-title'>Page Title</h1> <hr class='uk-article-divider' /> Body Content </article> */
  20. This is not clear like my array solution. I don't want syntax like this. My syntax will like (Module Usage) : <?php // All Configs $config = array( 'htmlFormatter' => true, 'indentWith' => ' ', 'tagsWithoutIndentation' => 'html,link,img,meta', 'page' => null, 'tag' => null, 'tagSelfClosed' => null, 'prepend' => '', 'prepends' => '', 'attributes' => '', 'dataAttributes' => '', 'label' => '', 'note' => '', 'text' => '', 'texts' => array(), 'field' => '', 'field_value' => '', 'fields' => array(), 'loop' => '', 'child' => '', 'children' => '', 'append' => '', 'appends' => '' ); // All Methods $page->html(array('key', 'value')) // $config ->tag('string', array('key', 'value')) // tag name, quick attributes ->attributes(array('key', 'value')) // attributes ->dataAttributes(array('key', 'value')) // data-attributes, this will add auto data- prefix to your attribute ->prepend('string') // a string value ->prepends(array('values')) // array for values ->text('string') // text for inner tag ->field('field_name', 'page_object') // Field name and page object ->loop() // !! will work on this !! ->texts(array()) // !! will work on this !! ->fields(array()) // !! Will work on this !! ->note() // !! will work on this !! ->label() // !! Will work on this !! ->append('string') // a string value ->appends(array('values')) // array for values ->render() // This will return result ->output(); // This will print result $title = $page->html('title')->tag('h1', array('class'=>'h1-class'))->render(); echo $title; // This will directly print $page->html('title')->tag('h1', array('class'=>'h1-class'))->output(); // Self Closed Tag $modules->AvbMarkupHtml->html()->tag('hr:/')->output(); // Example #1 $page->html('title')->tag('h1', array('class' => 'my-h1-title'))->output(); // Example #2 $page->html('title', $pages->get('/contact/'))->tag('h1', array('class' => 'my-h1-title'))->output(); // Example #3 $modules->AvbMarkupHtml->html()->tag('div', array('class' => 'container'))->children(array( $page->html('title')->tag('h1', array('class' => 'my-title'))->render(), $page->html('body')->tag('div', array('class' => 'my-body'))->render() ))->output(); // Example #4 | Multiple child, prepend, append $html = $page->html()->tag('div', array('class' => 'uk-container uk-container-center')); $html->prepend( $page->html()->tag('div')->text('Prepend #1 !')->render() ); $html->prepend( $page->html()->tag('div')->text('Prepend #2 !')->render() ); $html->child( $page->html()->tag('div')->text('Hey !')->render() ); $html->child( $page->html()->tag('div')->text('Foo !')->render() ); $html->child( $page->html()->tag('div')->text('Bar !')->render() ); $html->append( $page->html()->tag('div')->text('Append #1 !')->render() ); $html->append( $page->html()->tag('div')->text('Append #2 !')->render() ); $html->output(); // Example #5 | Create A HTML page // Create Html Tag $html = $page->html()->tag('html', array( 'lang' => 'en', 'dir' => 'ltr' )); // Create Head Tag $head = $page->html()->tag('head'); // Add TITLE inside HEAD tag $head->child( $page->html()->tag('title')->text('My Website')->render() ); // Put HEAD inside HTML Tag $html->child($head->render()); // Create BODY Tag $body = $page->html()->tag('body', array('class' => $page->template)); // Create DIV Tag $container = $page->html()->tag('div', array('class' => 'container')); $container->children(array( $page->html()->tag('h1', array('class' => 'h1-title'))->text('H1 Title')->render(), $page->html()->tag('div', array('class' => 'body-content'))->text('Body Content')->render() )); // Put DIV.container inside BODY Tag $body->child($container->render()); // Put BODY inside HTML Tag $html->child($body->render()); $html->output(); /* OUTPUT <html lang='en' dir='ltr'> <head> <title> My Website </title> </head> <body class='homepage'> <div class='container'> <h1 class='h1-title'> H1 Title </h1> <div class='body-content'> Body Content </div> </div> </body> </html> */ ?>
  21. @LostKobrakai above answer not for you : I don't need a template engine or a js library. I write this function like i said, Use less html elements inside your php codes ! its for first comment. I converted markup to a module and working on it. Can you check here and if you have time can you check usage ? https://github.com/trk/AvbMarkupHtml i will update repo if have have new things
  22. Your PHP version not supporting new array syntax, this is why you have this error message. I updated module to ve 0.1.0 now i think module fully supporting old php versions. New features for v.0.1.0 : Custom CSS file url support Added hook method ___beforeRender(), you can check hook example for usage Added multiple icons library use option Added Ionicons Library Now module using cdn for load icon fonts
  23. I don't need a template engine or a js library. I write this function like i said, Use less html elements inside your php codes ! @LostKobrakai For syntax maybe something like this could be helpful : - $page->title('h1'); - $page->title->output(array('tag' => 'h1', 'attributes' => array('class' => 'my-page-title')); - $pages->get(1)->children->output(array('tag' => 'li', 'attributes' => array('class' => 'my-child-item'), 'field' => 'title'));
  24. I, bored to write HTML elements inside my PHP code and i wrote a function for use less HTML elements. I think this function also could be helpful for you and maybe we can extend this function for use with all field types. For the moment the function only supporting fields like text, textarea or like these fields. What is this function making ? - Simply this function helping you to write less HTML elements in your PHP code. For the moment its only a function maybe i can make it a module. If you interest, here is gist link : https://gist.github.com/trk/b365f47793927006b1fb Module Usage (Available configs): <?php // Available configs $AvbMarkupOutputConfigs = array( 'tag' => 'div', // Usage for self closed tag : 'hr:/', 'i:/' 'attributes' => array( 'class' => 'element-class', // output : class='element-class' 'id' => 'element-id' // output : id='element-id' // Attributes ), 'data-attributes' => array( 'lat' => 'a-data-attribute' // output: data-lat='a-data-attribute' // Data Attributes : enter like normal attributes output will be data-your-attribute ), 'prepend' => array( // You can use here like main ), 'prepends' => array( array( // You can use here like main ), array( // You can use here like main ) // ..... ), 'field' => 'title', // a field name from your page 'value' => 'a custom value', 'loop' => array( 'tag' => 'div', // Usage for self closed tag : 'hr:/', 'i:/' 'attributes' => array( 'class' => 'element-class', // output : class='element-class' 'id' => 'element-id' // output : id='element-id' // Attributes ), 'data-attributes' => array( 'lat' => 'a-data-attribute' // output: data-lat='a-data-attribute' // Data Attributes : enter like normal attributes output will be data-your-attribute ), 'prepend' => array( // You can use here like main ), 'prepends' => array( array( // You can use here like main ), array( // You can use here like main ) // ..... ), 'fields' => array( 'title', 'body' // Field names from your page ), 'values' => array( 'Custom Value 1', 'Custom Value 2', 'Custom Value 3' // You can use custom values for here ), 'append' => array( // You can use here like main ), 'appends' => array( array( // You can use here like main ), array( // You can use here like main ) // ..... ) ), 'child' => array( // You can use here like main ), 'children' => array( array( // You can use here like main ), array( // You can use here like main ) // ..... ), 'append' => array( // You can use here like main ), 'appends' => array( array( // You can use here like main ), array( // You can use here like main ) // ..... ), ); AvbMarkupOutput($AvbMarkupOutputConfigs, $page) ?> Here are some examples about usage, i will make a before this function and after this function : Before : <?php $additionals = "foo bar some custom data"; echo "\n<article class='uk-article'> \n\t<h1 class='uk-article-title'>{$page->title}</h1> \n\t<hr class='uk-article-divider' /> \n\t{$page->body} \n\t{$additionals} \n</article>"; ?> After : <?php $additionals = "foo bar some custom data"; echo AvbMarkupOutput(array( 'tag' => 'article', 'attributes' => array( 'class' => 'uk-article' ), 'children' => array( array( 'tag' => 'h1', 'attributes' => array( 'class' => 'uk-article-title' ), 'field' => 'title', 'append' => array( 'tag' => 'hr:/', 'attributes' => array( 'class' => 'uk-article-divider' ) ) ), array( 'field' => 'body' ), array( 'value' => $additionals ) ) )); ?> Dive deep : <?php echo AvbMarkupOutput(array( 'tag' => 'div', 'attributes' => array( 'class' => 'uk-container uk-container-center' ), 'child' => array( 'tag' => 'section', 'attributes' => array( 'class' => 'page' ), 'child' => array( 'tag' => 'article', 'attributes' => array( 'class' => 'uk-article' ), 'children' => array( array( 'tag' => 'h1', 'attributes' => array( 'class' => 'uk-article-title' ), 'field' => 'title', 'append' => array( 'tag' => 'hr:/', 'attributes' => array( 'class' => 'uk-article-divider' ) ) ), array( 'field' => 'body' ) ) ) ) )); ?> <!-- Output --> <div class='uk-container uk-container-center'> <section class='page'> <article class='uk-article'> <h1 class='uk-article-title'><?=$page->title;?></h1> <hr class='uk-article-divider'/> <?=$page->body?> </article> </section> </div> <?php // Create a table same like this :: http://getuikit.com/docs/table.html#usage echo AvbMarkupOutput(array( 'tag' => 'table', 'attributes' => array( 'class' => 'uk-table' ), 'children' => array( array( 'tag' => 'caption', 'value' => 'Table caption' ), array( 'tag' => 'thead', 'child' => array( 'tag' => 'tr', 'child' => array( 'loop' => array( 'tag' => 'th', 'values' => array( 'Table Heading', 'Table Heading', 'Table Heading', 'Table Heading' ) ) ) ) ), array( 'tag' => 'tfoot', 'child' => array( 'tag' => 'tr', 'child' => array( 'loop' => array( 'tag' => 'td', 'values' => array( 'Table Footer', 'Table Footer', 'Table Footer', 'Table Footer' ) ) ) ) ), array( 'tag' => 'tbody', 'child' => array( 'children' => array( array( 'tag' => 'tr', 'child' => array( 'loop' => array( 'tag' => 'td', 'values' => array( 'Table Data', 'Table Data', 'Table Data', 'Table Data' ) ) ) ), array( 'tag' => 'tr', 'child' => array( 'loop' => array( 'tag' => 'td', 'values' => array( 'Table Data', 'Table Data', 'Table Data', 'Table Data' ) ) ) ), array( 'tag' => 'tr', 'child' => array( 'loop' => array( 'tag' => 'td', 'values' => array( 'Table Data', 'Table Data', 'Table Data', 'Table Data' ) ) ) ), array( 'tag' => 'tr', 'child' => array( 'loop' => array( 'tag' => 'td', 'values' => array( 'Table Data', 'Table Data', 'Table Data', 'Table Data' ) ) ) ) ) ) ) ) )); ?> <!-- Output --> <table class='uk-table'> <caption>Table caption</caption> <thead> <tr> <th>Table Heading</th> <th>Table Heading</th> <th>Table Heading</th> <th>Table Heading</th> </tr> </thead> <tfoot> <tr> <td>Table Footer</td> <td>Table Footer</td> <td>Table Footer</td> <td>Table Footer</td> </tr> </tfoot> <tbody> <tr> <td>Table Data</td> <td>Table Data</td> <td>Table Data</td> <td>Table Data</td> </tr> <tr> <td>Table Data</td> <td>Table Data</td> <td>Table Data</td> <td>Table Data</td> </tr> <tr> <td>Table Data</td> <td>Table Data</td> <td>Table Data</td> <td>Table Data</td> </tr> <tr> <td>Table Data</td> <td>Table Data</td> <td>Table Data</td> <td>Table Data</td> </tr> </tbody> </table> You can make nested calls !
  25. @kongondo Thanks for your module ! I made a pull-request for separating status urls from status labels. I opened an issue for original ProcessCommentsManager, because problem coming from the original module. On my side i am using your module with my changes its look like working well !
×
×
  • Create New...