function _insert_view_substitute_tags in Insert View 6.2
Same name and namespace in other branches
- 5 insert_view.module \_insert_view_substitute_tags()
- 6 insert_view.module \_insert_view_substitute_tags()
- 7.2 insert_view.module \_insert_view_substitute_tags()
Helper function to replace the tag syntax with the actual view.
1 call to _insert_view_substitute_tags()
- insert_view_filter in ./
insert_view.module - Implementation of hook_filter().
File
- ./
insert_view.module, line 54 - Insert view.
Code
function _insert_view_substitute_tags($text) {
if (preg_match_all("/\\[view:([^=\\]]+)=?([^=\\]]+)?=?([^\\]]*)?\\]/i", $text, $match)) {
foreach ($match[0] as $key => $value) {
$view_name = $match[1][$key];
$display_id = $match[2][$key] && !is_numeric($match[2][$key]) ? $match[2][$key] : 'default';
$args = $match[3][$key];
$view_output = insert_view($view_name, $display_id, $args);
$search[] = $value;
$replace[] = !empty($view_output) ? $view_output : '';
}
return str_replace($search, $replace, $text);
}
return $text;
}