Skip to content

Commit

Permalink
More custom classes possible via template defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
slackero committed Feb 16, 2013
1 parent 5efddd7 commit c4349f7
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 63 deletions.
23 changes: 22 additions & 1 deletion config/phpwcms/conf.template_default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,32 @@
'link-bookmark' => 'link-bookmark',
'link-rss' => 'link-rss',
'spaceholder' => 'spaceholder',
'spaceholder-cp-after' => 'spaceAfterCP',
'spaceholder-cp-before' => 'spaceBeforeCP',
'img-list-right' => 'img-list-right',
'search-nextprev' => 'search-nextprev',
'search-result' => 'search-result',
'search-result-item' => 'search-result-item',
'article-list-paginate' => 'article-list-paginate'
'article-list-paginate' => 'article-list-paginate',
'tab-container' => 'tab-container',
'tab-navigation' => 'tab-navigation',
'tab-first' => 'tab-first',
'tab-last' => 'tab-last',
'tab-content' => 'tab-content',
'tab-container-clear' => 'tab-container-clear',
'tab-item' => 'tab-item',
'navlist-sub_ul_true' => 'sub_ul_true',
'navlist-sub_ul' => 'sub_ul',
'navlist-sub_no' => 'sub_no',
'navlist-sub_first' => 'sub_first',
'navlist-sub_last' => 'sub_last',
'navlist-sub_parent' => 'sub_parent',
'navlist-asub_no' => 'asub_no',
'navlist-asub_first' => 'asub_first',
'navlist-asub_last' => 'asub_last',
'navlist-navLevel' => 'navLevel-',
'breadcrumb-active' => 'active',
'cp-anchor' => 'cpidClass'
);


Expand Down
26 changes: 14 additions & 12 deletions include/inc_front/content.article.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,15 @@

// each content part will get an anchor
if($crow["acontent_anchor"]) {
$CNT_TMP .= '<a name="cpid'.$crow["acontent_id"].'" id="cpid'.$crow["acontent_id"].'" class="cpidClass"></a>';
$CNT_TMP .= '<a name="cpid'.$crow["acontent_id"].'" id="cpid'.$crow["acontent_id"].'" class="'.$template_default['classes']['cp-anchor'].'"></a>';
}

// Space before
if($crow["acontent_before"]) {
if(!empty($template_default["article"]["div_spacer"])) {
$CNT_TMP .= '<div style="margin:'.$crow["acontent_before"].'px 0 0 0;padding:0;" class="spaceBeforeCP"></div>';
$CNT_TMP .= '<div style="margin:'.$crow["acontent_before"].'px 0 0 0;padding:0;" class="'.$template_default['classes']['spaceholder-cp-before'].'"></div>';
} else {
$CNT_TMP .= '<br class="spaceBeforeCP" />'.spacer(1,$crow["acontent_before"]);
$CNT_TMP .= '<br class="'.$template_default['classes']['spaceholder-cp-before'].'" />'.spacer(1,$crow["acontent_before"]);
}
}

Expand Down Expand Up @@ -524,9 +524,9 @@
// Space after
if($crow["acontent_after"]) {
if(!empty($template_default["article"]["div_spacer"])) {
$CNT_TMP .= '<div style="margin:0 0 '.$crow["acontent_after"].'px 0;padding:0;" class="spaceAfterCP"></div>';
$CNT_TMP .= '<div style="margin:0 0 '.$crow["acontent_after"].'px 0;padding:0;" class="'.$template_default['classes']['spaceholder-cp-after'].'"></div>';
} else {
$CNT_TMP .= '<br class="spaceAfterCP" />'.spacer(1,$crow["acontent_after"]);
$CNT_TMP .= '<br class="'.$template_default['classes']['spaceholder-cp-after'].'" />'.spacer(1,$crow["acontent_after"]);
}
}

Expand Down Expand Up @@ -601,9 +601,9 @@
// define helper var
$g = array('wrap' => array(), 'cnt' => array(), 'counter' => 1, 'max' => count($trow), 'href' => rel_url());

$g['wrap'][] = '<div id="'.$CNT_TAB.'" class="tab-container">';
$g['wrap'][] = '<div id="'.$CNT_TAB.'" class="'.$template_default['classes']['tab-container'].'">';

$g['wrap'][] = ' <ul class="tab-navigation">';
$g['wrap'][] = ' <ul class="'.$template_default['classes']['tab-navigation'].'">';

foreach($trow as $tabkey => $tabitem) {

Expand All @@ -612,22 +612,24 @@
$tabitem['class'] = '';

if($g['counter'] === 1) {
$tabitem['class'] .= ' tab-first';
$tabitem['class'] .= ' '.$template_default['classes']['tab-first'];
}
if($g['counter'] === $g['max']) {
$tabitem['class'] .= ' tab-last';
$tabitem['class'] .= ' '.$template_default['classes']['tab-last'];
}

$g['wrap'][] = ' <li class="tab-item-'.$g['counter'].$tabitem['class'].'"><a href="'.$g['href'].'#'.$tabitem['id'].'" title="'.$tabitem['title'].'">'.$tabitem['title'].'</a></li>';
$g['cnt'][] = ' <div id="'.$tabitem['id'].'" class="tab-content">' . LF . $tabitem['content'] . LF . ' </div>';
$g['wrap'][] = ' <li class="'.$template_default['classes']['tab-item'].'-'.$g['counter'].$tabitem['class'].'"><a href="'.$g['href'].'#'.$tabitem['id'].'" title="'.$tabitem['title'].'">'.$tabitem['title'].'</a></li>';
$g['cnt'][] = ' <div id="'.$tabitem['id'].'" class="'.$template_default['classes']['tab-content'].'">' . LF . $tabitem['content'] . LF . ' </div>';

$tab_counter++;
$g['counter']++;
}

$g['wrap'][] = ' </ul>';
$g['wrap'][] = implode(LF, $g['cnt']);
$g['wrap'][] = ' <div class="tab-container-clear"></div>';
if($template_default['classes']['tab-container-clear']) {
$g['wrap'][] = ' <div class="'.$template_default['classes']['tab-container-clear'].'"></div>';
}
$g['wrap'][] = '</div>';

$content['cptab'][$CNT_TAB] = implode(LF, $g['wrap']);
Expand Down
40 changes: 2 additions & 38 deletions include/inc_front/content.func.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,45 +302,9 @@

// template defaults
if(isset($template_default['classes'])) {

$template_default['classes'] = array_merge(array(
'link-top' => 'link-top',
'link-internal' => 'link-internal',
'link-external' => 'link-external',
'link-rss' => 'link-rss',
'link-back' => 'link-back',
'link-anchor' => 'link-anchor',
'link-email' => 'link-email',
'link-bookmark' => 'link-bookmark',
'link-rss' => 'link-rss',
'spaceholder' => 'spaceholder',
'img-list-right' => 'img-list-right',
'search-nextprev' => 'search-nextprev',
'search-result' => 'search-result',
'search-result-item' => 'search-result-item',
'article-list-paginate' => 'article-list-paginate'
), $template_default['classes']);

$template_default['classes'] = array_merge($phpwcms['default_template_classes'], $template_default['classes']);
} else {

$template_default['classes'] = array(
'link-top' => 'link-top',
'link-internal' => 'link-internal',
'link-external' => 'link-external',
'link-rss' => 'link-rss',
'link-back' => 'link-back',
'link-anchor' => 'link-anchor',
'link-email' => 'link-email',
'link-bookmark' => 'link-bookmark',
'link-rss' => 'link-rss',
'spaceholder' => 'spaceholder',
'img-list-right' => 'img-list-right',
'search-nextprev' => 'search-nextprev',
'search-result' => 'search-result',
'search-result-item' => 'search-result-item',
'article-list-paginate' => 'article-list-paginate'
);

$template_default['classes'] = $phpwcms['default_template_classes'];
}

// check if template_defaults should be overwritten
Expand Down
30 changes: 18 additions & 12 deletions include/inc_front/front.func.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

function spacer($width=1, $height=1) {
//creates a placeholder image (transparent gif)
return '<img src="img/leer.gif" width="'.intval($width).'" height="'.intval($height).'" border="0" alt="" />';
return '<span style="display:inline-block;width:'.intval($width).'px;height:'.intval($height).'px" class="'.$GLOBALS['template_default']['classes']['spaceholder'].'"></span>';
}

function headline(& $head, & $subhead, & $layout) {
Expand Down Expand Up @@ -374,10 +374,10 @@ function breadcrumb($start_id, &$struct_array, $end_id, $spacer=' &gt; ') {
if(!$struct_array[$key]["acat_redirect"]) {
$breadcrumb[$key] .= '<a href="index.php?';
$breadcrumb[$key] .= $struct_array[$key]["acat_alias"] ? html_specialchars($struct_array[$key]["acat_alias"]) : 'id='.$key;
$breadcrumb[$key] .= '" class="active">';
$breadcrumb[$key] .= '" class="'.$GLOBALS['template_default']['classes']['breadcrumb-active'].'">';
} else {
$redirect = get_redirect_link($struct_array[$key]["acat_redirect"], ' ', '');
$breadcrumb[$key] .= '<a href="'.$redirect['link'].'"'.$redirect['target'].' class="active">';
$breadcrumb[$key] .= '<a href="'.$redirect['link'].'"'.$redirect['target'].' class="'.$GLOBALS['template_default']['classes']['breadcrumb-active'].'">';
}

if(!empty($GLOBALS['template_default']['breadcrumb_active_prefix'])) {
Expand All @@ -403,7 +403,7 @@ function breadcrumb($start_id, &$struct_array, $end_id, $spacer=' &gt; ') {

$breadcrumb['article'] = '<a href="index.php?';
$breadcrumb['article'] .= defined('PHPWCMS_ALIAS') ? html_specialchars(PHPWCMS_ALIAS) : 'aid='.$GLOBALS['content']["article_id"];
$breadcrumb['article'] .= '" class="active">';
$breadcrumb['article'] .= '" class="'.$GLOBALS['template_default']['classes']['breadcrumb-active'].'">';

if(!empty($GLOBALS['template_default']['breadcrumb_active_prefix'])) {
$breadcrumb['article'] .= $GLOBALS['template_default']['breadcrumb_active_prefix'];
Expand Down Expand Up @@ -3044,9 +3044,9 @@ class_active_li|class_active_a,
$parameter[12]['item_tag'] = 'li';
$parameter[12]['wrap_tag'] = '';
$parameter[12]['attribute_wrap_tag'] = '';
$parameter[12]['class_item_tag'] = 'asub_no';
$parameter[12]['class_first_item_tag'] = 'asub_first';
$parameter[12]['class_last_item_tag'] = 'asub_last';
$parameter[12]['class_item_tag'] = $GLOBALS['template_default']['classes']['navlist-asub_no'];
$parameter[12]['class_first_item_tag'] = $GLOBALS['template_default']['classes']['navlist-asub_first'];
$parameter[12]['class_last_item_tag'] = $GLOBALS['template_default']['classes']['navlist-asub_last'];
$parameter[12]['return_format'] = 'array';
}

Expand Down Expand Up @@ -3108,21 +3108,27 @@ class_active_li|class_active_a,
if($level_id_name) {
$li .= ' id="li_'.$level_id_name.'_'.$key.'"';
}
$li_class = ($li_ul) ? 'sub_ul' : (getHasSubStructureStatus($key) ? 'sub_no sub_ul_true' : 'sub_no');
if($li_ul) {
$li_class = $GLOBALS['template_default']['classes']['navlist-sub_ul'];
} elseif(getHasSubStructureStatus($key)) {
$li_class = $GLOBALS['template_default']['classes']['navlist-sub_no'].' '.$GLOBALS['template_default']['classes']['navlist-sub_ul_true'];
} else {
$li_class = $GLOBALS['template_default']['classes']['navlist-sub_no'];
}
if($path_class[0] && isset($GLOBALS['LEVEL_KEY'][$key])) {
$li_class = trim($li_class.' '.$path_class[0]);
}
if($active_class[0] != '' && $key == $GLOBALS['aktion'][0]) {
$li_class = trim($li_class.' '.$active_class[0]);
}
if($x==0) {
$li_class .= ' sub_first';
$li_class .= ' '.$GLOBALS['template_default']['classes']['navlist-sub_first'];
}

$x++;

if($x==$last_item) {
$li_class .= ' sub_last';
$li_class .= ' '.$GLOBALS['template_default']['classes']['navlist-sub_last'];
}

$li .= ' class="' . trim($li_class . ' ' . $GLOBALS['content']['struct'][$key]['acat_class']) .'"';
Expand Down Expand Up @@ -3164,7 +3170,7 @@ class_active_li|class_active_a,
case 2: $ul = LF.$TAB.'<div id="ul_div_'.$start_id.'">';
$close_wrap_ul = '</div>'.LF.$TAB;
break;
case 3: $ul = LF.$TAB.'<div class="navLevel-'.$counter.'">';
case 3: $ul = LF.$TAB.'<div class="'.$GLOBALS['template_default']['classes']['navlist-navLevel'].$counter.'">';
$close_wrap_ul = '</div>'.LF.$TAB;
break;
default: $ul = '';
Expand Down Expand Up @@ -3192,7 +3198,7 @@ class_active_li|class_active_a,
if($level_id_name) {
$ul .= ' id="li_'.$level_id_name.'_'.$start_id.'"';
}
$li_class = 'sub_parent';
$li_class = $GLOBALS['template_default']['classes']['navlist-sub_parent'];
if($active_class[0] != '' && $start_id == $GLOBALS['aktion'][0]) {
$li_class = trim($li_class.' '.$active_class[0]);
}
Expand Down
39 changes: 39 additions & 0 deletions include/inc_lib/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,45 @@ function mb_strlen($str='', $encoding='') {
);
}

$phpwcms['default_template_classes'] = array(
'link-top' => 'link-top',
'link-internal' => 'link-internal',
'link-external' => 'link-external',
'link-rss' => 'link-rss',
'link-back' => 'link-back',
'link-anchor' => 'link-anchor',
'link-email' => 'link-email',
'link-bookmark' => 'link-bookmark',
'link-rss' => 'link-rss',
'spaceholder' => 'spaceholder',
'spaceholder-cp-after' => 'spaceAfterCP',
'spaceholder-cp-before' => 'spaceBeforeCP',
'img-list-right' => 'img-list-right',
'search-nextprev' => 'search-nextprev',
'search-result' => 'search-result',
'search-result-item' => 'search-result-item',
'article-list-paginate' => 'article-list-paginate',
'tab-container' => 'tab-container',
'tab-navigation' => 'tab-navigation',
'tab-first' => 'tab-first',
'tab-last' => 'tab-last',
'tab-content' => 'tab-content',
'tab-container-clear' => 'tab-container-clear',
'tab-item' => 'tab-item',
'navlist-sub_ul_true' => 'sub_ul_true',
'navlist-sub_ul' => 'sub_ul',
'navlist-sub_no' => 'sub_no',
'navlist-sub_first' => 'sub_first',
'navlist-sub_last' => 'sub_last',
'navlist-sub_parent' => 'sub_parent',
'navlist-asub_no' => 'asub_no',
'navlist-asub_first' => 'asub_first',
'navlist-asub_last' => 'asub_last',
'navlist-navLevel' => 'navLevel-',
'breadcrumb-active' => 'active',
'cp-anchor' => 'cpidClass'
);

if(empty($phpwcms['mode_XHTML'])) {

$phpwcms['mode_XHTML'] = 0;
Expand Down

2 comments on commit c4349f7

@jensensen
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
But one step to get >>More custom classes<< is still missing.
Many --> image links for modern css frameworks require that you can add e.g.

  1. --> a href class >ABC_something< or
  2. --> img class >XYZ_something<

with ---> the common {image} tag that is used in ---> nearly all templates you can't do it.
you can break up the standard by using cmsimage.php but you still get and have many problems.

the phpwcms standard is:
div
{image}
/div

{image} is rendering [by default/script/internal/no hack]
a img
but you CAN'T include any custom classes to A or IMG.

the DIV wrapper outside is helpful but you must rewrite and add styles to your css files.
THAT'S WHY THERE IS NO CSS FRAMEWORK ON THE WORLD THAT CAN BE APPLIED EASILY!

it would be a great advantage when you could add custom classes INTO/WITHIN -->> {image}

  1. to the A -tag
  2. to the IMG -tag
    when using --any-- IMG content part

result could/should be:
a href class="MY_ABC"
img src class="MY_XYZ"
/a

@slackero
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See Issue #19

Please sign in to comment.