Convert UTF-8 to korean letters
<?php
$test="포럼";
$test2 = iconv("UTF-8", "EUC-KR", $test);
echo $test2;
echo '<br/>';
echo gettype($test2); //returns operator' value
?>
<?php
$forum_word="포럼";
$converted_forum = iconv("UTF-8", "EUC-KR", $forum_word);
$converted_forums = utf8_encode($forum_word); //same as above
$forum_string = drupal_strtolower($converted_forum);
// Convert the Drupal path to lowercase
$current_path = drupal_strtolower(drupal_get_path_alias($_GET["q"]));
$path_forum = strstr($current_path, '/', true); //string on the left from slash
// Compare the lowercase internal and lowercase path alias (if any).
$page_match_forum = strcmp($path_forum, $forum_string);
if ($page_match_forum) {
//do something
}
?>
Rules to invoke css or js or other snippet according to a specific terms:
/**
* forum styles for mobile and desktop versions
*/
function advanced_forum_ismobile_init() {
require_once 'sites/all/libraries/Mobile_Detect/Mobile_Detect.php';
$detect = mobile_detect_get_object();
$is_mobile = $detect->isMobile();
$url = request_uri();
// block is visible on the content types entered here
$types = array('forum' => 1);
$nid = arg(1); //2nd parameter after / defines ARGUMENT #1 - NODE ID
// $node = node_load($nid); - BAD INVOKATION - conflicts with the nodeblock
$node = node_load($node->nid);
$type = $node->type;
if ($is_mobile AND arg(0) == 'forum' || arg(0) == 'forums' || (isset($types[$type]))) {
drupal_add_css(drupal_get_path('module', 'advanced_forum') . '/styles/mobile.css', array('preprocess' => TRUE));
}
elseif (!$is_mobile AND arg(0) == 'forum' || arg(0) == 'forums') {
drupal_add_css(drupal_get_path('module', 'advanced_forum') . '/styles/desktop.css', array('preprocess' => TRUE));
}
}
advanced_forum_ismobile_init();
MORE RELIABLE VARIANT (SUPPORTS non-UTF String)
/**
* forum styles for mobile and desktop versions
*/
function advanced_forum_ismobile_init() {
require_once 'sites/all/libraries/Mobile_Detect/Mobile_Detect.php';
$detect = mobile_detect_get_object();
$is_mobile = $detect->isMobile();
$forum_word="포럼";
$conv_forum = iconv("UTF-8", "EUC-KR", $forum_word);
$url = request_uri();
// block is visible on the content types entered here
$types = array('forum' => 1);
$nid = arg(1); //2nd parameter after / defines ARGUMENT #1 - NODE ID
// $node = node_load($nid); - BAD INVOKATION - conflicts with the nodeblock
$node = node_load($node->nid);
$type = $node->type;
$forum_pages = array(
'forum',
'forums',
"$conv_forum"
);
// Implode paths
$forum_pages = implode("\n",$forum_pages);
// Convert the Drupal path to lowercase
$path_forum = drupal_strtolower(drupal_get_path_alias($_GET['q']));
// Compare the lowercase internal and lowercase path alias (if any).
$page_match_forum = drupal_match_path($path_forum, $path_forum);
if ($is_mobile && $page_match_forum || (isset($types[$type]))) {
drupal_add_css(drupal_get_path('module', 'advanced_forum') . '/styles/mobile.css.less', array('preprocess' => TRUE));
}
elseif (!$is_mobile && $page_match_forum || (isset($types[$type]))) {
drupal_add_css(drupal_get_path('module', 'advanced_forum') . '/styles/desktop.css.less', array('preprocess' => TRUE));
}
}
advanced_forum_ismobile_init();