I would like to know how I can do to change the links depending on where I am on my site?
For example, I would like that when I click on "Sign In", it is like this:
Forums > Sign In
http://prntscr.com/47d04a
container.php:
<div class="wrapper">
<div id="container">
<div id="breadcrumb_top">
<div class="breadcrumb_links">
<ul>
<li class="forums">
Forums
</li>
</ul>
</div>
</div>
<?php
if(strpos($_SERVER["REQUEST_URI"], "index") !== false) {
echo "<h1 style='margin-bottom: 15px;'>Forums</h1>";
/* Code here. */
}
?>
<?php
if(strpos($_SERVER["REQUEST_URI"], "members") !== false) {
echo "<h1 style='margin-bottom: 15px;'>Members</h1>";
/* Code here. */
}
?>
<?php
if(strpos($_SERVER["REQUEST_URI"], "sign_up") !== false) {
echo "<h1 style='margin-bottom: 15px;'>Sign Up</h1>";
/* Code here. */
}
?>
<?php
if(strpos($_SERVER["REQUEST_URI"], "sign_in") !== false) {
echo "<h1 style='margin-bottom: 15px;'>Sign In</h1>";
/* Code here. */
}
?>
<?php
if(strpos($_SERVER["REQUEST_URI"], "change_theme") !== false) {
echo "<h1 style='margin-bottom: 15px;'>Change Theme</h1>";
/* Code here. */
}
?>
<?php
if(strpos($_SERVER["REQUEST_URI"], "contact_us") !== false) {
echo "<h1 style='margin-bottom: 15px;'>Contact Us</h1>";
/* Code here. */
}
?>
<?php
if(strpos($_SERVER["REQUEST_URI"], "help") !== false) {
echo "<h1 style='margin-bottom: 15px;'>Help</h1>";
/* Code here. */
}
?>
<?php
if(strpos($_SERVER["REQUEST_URI"], "rules") !== false) {
echo "<h1 style='margin-bottom: 15px;'>Rules</h1>";
/* Code here. */
}
?>
<div id="breadcrumb_bottom">
<div class="breadcrumb_links">
<ul>
<li class="forums">
Forums
</li>
</ul>
</div>
</div>
</div>
</div>
I would like that everything be automated depending on where I am. If I click on "Members" in the top_bar, I would like that "Forums" in the breadcrumb should be replaced by "Members", etc.
Thanks.
At the top of my pages I'll create some PHP variables or constants that describe what the page name, parent and title are and then use a function to determine what page I'm on by what's defined/set.
This is an idea of what it's like.
<?php
define('PARENT','Blog'); // the site section/parent
define('PAGE','Posts'); // the child page under the site section
$page_title = 'My Blog'; // the page's title
function active($str, $submenu='') {
if(!defined(PARENT) || !defined(PAGE)) {
return false;
}
if($submenu) {
if($str == PARENT) {
return ' visible';
}
} else {
if($str == PARENT || $str == PAGE) {
return ' class="active selected"';
}
}
return false;
}
echo $page_title;
?>
<ul class="submenu<?php echo active('Blog', 'submenu') ?>">
<li<?php echo active('Posts') ?>>
Posts
</li>
</ul>
Related
I am using a foreach loop to look at custom taxonomies associated with my custom post type. The issue I am having is that I am getting multiple buttons to display for posts that have more than one tax term selected.
What I would like to have happen is the loop search for one or more of the "age/grades" and then display a single button with the correct text and link. However, I am getting one button for each grade selected for the program (e.g. a Grade 3-6 program has four buttons: one for each applicable grade).
Any idea on how to prevent the duplicates?
Here is my current code:
<?php
$agegroup = wp_get_post_terms(get_the_ID(), 'camper_grade');
if ($agegroup) {
foreach ($agegroup as $group) {
if ($group->slug == 'age-2' || 'age-3' || 'age-4') { ?>
<a href="/preschool">
<div class="blue-btn">
More Preschool Camps
</div>
</a> <?php ;
}
elseif ($group->slug == '1st-grade' || '2nd-grade' || '3rd-grade' || '4th-grade' || '5th-
grade' || '6th-grade') { ?>
<a href="/grades-k-6">
<div class="blue-btn">
More Grade K-6 Camps
</div>
</a> <?php ;
}
elseif ($group->slug == '7th-grade' || '8th-grade' || '9th-grade' || '10th-grade' || '11th-
grade' || '12th-grade' ) { ?>
<a href="/teen">
<div class="blue-btn">
More Teen Adventures
</div>
</a> <?php ;
}
}
}
?>
Use separate foreach loops and break when it's found.
Your || is also not working how you want it to. You should use in_array which correctly compares the same value to many others:
<?php
$agegroup = wp_get_post_terms(get_the_ID(), 'camper_grade');
if ($agegroup) {
foreach ($agegroup as $group) {
if (in_array($group->slug, ['age-2', 'age-3', 'age-4'])) { ?>
<a href="/preschool">
<div class="blue-btn">
More Preschool Camps
</div>
</a> <?php ;
break;
}
}
foreach ($agegroup as $group) {
if (in_array($group->slug, ['1st-grade', '2nd-grade', '3rd-grade', '4th-grade', '5th-grade', '6th-grade'])) { ?>
<a href="/grades-k-6">
<div class="blue-btn">
More Grade K-6 Camps
</div>
</a> <?php ;
break;
}
}
foreach ($agegroup as $group) {
if (in_array($group->slug, ['7th-grade', '8th-grade', '9th-grade', '10th-grade', '11th-grade', '12th-grade'])) { ?>
<a href="/teen">
<div class="blue-btn">
More Teen Adventures
</div>
</a> <?php ;
break;
}
}
}
?>
You need to add a flag to indicate whether the button has been displayed already for that group, and only output the button if it hasn't. Note that your logical conditions are incorrect, you need to compare the slug with each value individually (or better yet, use in_array). For example:
if ($agegroup) {
$preschool = $grades_k_6 = $teen = false;
foreach ($agegroup as $group) {
if (in_array($group->slug, array('age-2', 'age-3', 'age-4')) && !$preschool) { ?>
<a href="/preschool">
<div class="blue-btn">
More Preschool Camps
</div>
</a> <?php ;
$preschool = true;
}
elseif (in_array($group->slug, array('1st-grade', '2nd-grade', '3rd-grade', '4th-grade', '5th-grade', '6th-grade')) && !$grades_k_6) { ?>
<a href="/grades-k-6">
<div class="blue-btn">
More Grade K-6 Camps
</div>
</a> <?php ;
$grades_k_6 = true;
}
elseif (in_array($group->slug, array('7th-grade', '8th-grade', '9th-grade', '10th-grade', '11th-grade', '12th-grade')) && !$teen) { ?>
<a href="/teen">
<div class="blue-btn">
More Teen Adventures
</div>
</a> <?php ;
$teen = true;
}
}
}
I have a Jomi installation and I see that social icons are inserted at the bottom of my article while I would display them after the head section. What should I look for to modify this since the template settings just allow me to turn on/off the social bar? Should I look inside layouts or styles folder?
On feeling I looked into layouts/com_content/article and there is a default.php that looks something like a template for my articles, but I cannot find anything about social bar, here is its content:
<?php
/**
* #package Warp Theme Framework
* #author YOOtheme http://www.yootheme.com
* #copyright Copyright (C) YOOtheme GmbH
* #license http://www.gnu.org/licenses/gpl.html GNU/GPL
*/
// no direct access
defined('_JEXEC') or die;
// get view
$menu = JSite::getMenu()->getActive();
$view = is_object($menu) && isset($menu->query['view']) ? $menu->query['view'] : null;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
// Create shortcuts to some parameters.
$params = $this->item->params;
$images = json_decode($this->item->images);
$urls = json_decode($this->item->urls);
$canEdit = $this->item->params->get('access-edit');
$user = JFactory::getUser();
?>
<div id="system">
<?php if ($this->params->get('show_page_heading', 1)) : ?>
<h1 class="title"><?php echo $this->escape($this->params->get('page_heading')); ?></h1>
<?php endif; ?>
<article class="item"<?php if ($view != 'article') printf(' data-permalink="%s"', JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catslug), true, -1)); ?>>
<?php if ($params->get('show_title')) : ?>
<header>
<?php if (!$this->print) : ?>
<?php if ($params->get('show_email_icon')) : ?>
<div class="icon email"><?php echo JHtml::_('icon.email', $this->item, $params); ?></div>
<?php endif; ?>
<?php if ($params->get('show_print_icon')) : ?>
<div class="icon print"><?php echo JHtml::_('icon.print_popup', $this->item, $params); ?></div>
<?php endif; ?>
<?php else : ?>
<div class="icon printscreen"><?php echo JHtml::_('icon.print_screen', $this->item, $params); ?></div>
<?php endif; ?>
<?php if ($params->get('show_create_date')) : ?>
<header class="clearfix">
<time datetime="<?php echo substr($this->item->created, 0,10); ?>" pubdate>
<span class="day"><?php echo JHTML::_('date',$this->item->created, JText::_('d')); ?></span>
<span class="month"><?php echo JHTML::_('date',$this->item->created, JText::_('M')); ?></span>
<span class="year"><?php echo JHTML::_('date',$this->item->created, JText::_('Y')); ?></span>
</time>
<?php endif; ?>
<h1 class="title"><?php echo $this->escape($this->item->title); ?></h1>
<?php if (($params->get('show_author') && !empty($this->item->author)) || $params->get('show_category')) : ?>
<p class="meta">
<?php
if ($params->get('show_author') && !empty($this->item->author )) {
$author = $this->item->created_by_alias ? $this->item->created_by_alias : $this->item->author;
if (!empty($this->item->contactid) && $params->get('link_author') == true) {
$needle = 'index.php?option=com_contact&view=contact&id=' . $this->item->contactid;
$menu = JFactory::getApplication()->getMenu();
$item = $menu->getItems('link', $needle, true);
$cntlink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
echo JText::sprintf('<i class="icon-user"></i>');
echo JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link', JRoute::_($cntlink), $author));
} else {
echo JText::sprintf('<i class="icon-user"></i>');
echo JText::sprintf('COM_CONTENT_WRITTEN_BY', $author);
}
}
if ($params->get('show_author') && !empty($this->item->author )) {
echo '. ';
}
if ($params->get('show_category')) {
echo JText::_('<i class="icon-folder-open-alt"></i>').' ';
echo JText::_('TPL_WARP_POSTED_IN').' ';
$title = $this->escape($this->item->category_title);
$url = ''.$title.'';
if ($params->get('link_category') AND $this->item->catslug) {
echo $url;
} else {
echo $title;
}
}
?>
</p>
<?php endif; ?>
</header>
<?php endif; ?>
<?php
if (!$params->get('show_intro')) {
echo $this->item->event->afterDisplayTitle;
}
echo $this->item->event->beforeDisplayContent;
if (isset ($this->item->toc)) {
echo $this->item->toc;
}
?>
<div class="content clearfix">
<?php
if ($params->get('access-view')) {
if (isset($urls) AND ((!empty($urls->urls_position) AND ($urls->urls_position=='0')) OR ($params->get('urls_position')=='0' AND empty($urls->urls_position) ))
OR (empty($urls->urls_position) AND (!$params->get('urls_position')))) {
echo $this->loadTemplate('links');
}
if (isset($images->image_fulltext) and !empty($images->image_fulltext)) {
$imgfloat = (empty($images->float_fulltext)) ? $params->get('float_fulltext') : $images->float_fulltext;
$class = (htmlspecialchars($imgfloat) != 'none') ? ' class="size-auto align-'.htmlspecialchars($imgfloat).'"' : ' class="size-auto"';
$title = ($images->image_fulltext_caption) ? ' title="'.htmlspecialchars($images->image_fulltext_caption).'"' : '';
echo '<img'.$class.$title.' src="'.htmlspecialchars($images->image_fulltext).'" alt="'.htmlspecialchars($images->image_fulltext_alt).'" />';
}
echo $this->item->text;
if (isset($urls) AND ((!empty($urls->urls_position) AND ($urls->urls_position=='1')) OR ( $params->get('urls_position')=='1') )) {
echo $this->loadTemplate('links');
}
// optional teaser intro text for guests
} elseif ($params->get('show_noauth') == true AND $user->get('guest')) {
echo $this->item->introtext;
// optional link to let them register to see the whole article.
if ($params->get('show_readmore') && $this->item->fulltext != null) {
$link1 = JRoute::_('index.php?option=com_users&view=login');
$link = new JURI($link1);
echo '<p class="links">';
echo '<a href="'.$link.'">';
$attribs = json_decode($this->item->attribs);
if ($attribs->alternative_readmore == null) {
echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
} elseif ($readmore = $this->item->alternative_readmore) {
echo $readmore;
if ($params->get('show_readmore_title', 0) != 0) {
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
}
} elseif ($params->get('show_readmore_title', 0) == 0) {
echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
} else {
echo JText::_('COM_CONTENT_READ_MORE');
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
}
echo '</a></p>';
}
}
?>
</div>
<?php if ($canEdit) : ?>
<p class="edit"><?php echo JHtml::_('icon.edit', $this->item, $params); ?> <?php echo JText::_('TPL_WARP_EDIT_ARTICLE'); ?></p>
<?php endif; ?>
<?php echo $this->item->event->afterDisplayContent; ?>
</article>
</div>
The only point that could reasonable be the social bar is this line:
<?php echo $this->item->event->afterDisplayContent; ?>
However it looks like a ore wider concept, since afterDisplayContent probably handles many things, and here is where I stop, I have no idea where to look for afterDisplayContent event definition, I guess that I should find an entry for social bar and copy/paste in the position that I want in my module.
I have a Wordpress site that is using Wp-Property and the pagination isn't working, can anyone help fix this please. Please see below the pagination part from the function page.
<?php if($use_pagination) { ?>
if(!wpp_pagination_<?php echo $unique_hash; ?>) {
jQuery("#wpp_shortcode_<?php echo $unique_hash; ?> .wpp_pagination_slider_wrapper").each(function() {
var this_parent = this;
/* Slider */
jQuery('.wpp_pagination_slider', this).slider({
value:1,
min: 1,
max: <?php echo $pages; ?>,
step: 1,
slide: function( event, ui ) {
/* Update page counter - we do it here because we want it to be instant */
jQuery("#wpp_shortcode_<?php echo $unique_hash; ?> .wpp_current_page_count").text(ui.value);
jQuery("#wpp_shortcode_<?php echo $unique_hash; ?> .wpp_pagination_slider .slider_page_info .val").text(ui.value);
},
stop: function(event, ui) {
wpp_query_<?php echo $unique_hash; ?> = changeAddressValue(ui.value, wpp_query_<?php echo $unique_hash; ?>);
}
});
/* Fix slider width based on button width */
var slider_width = (jQuery(this_parent).width() - jQuery(".wpp_pagination_back", this_parent).outerWidth() - jQuery(".wpp_pagination_forward", this_parent).outerWidth() - 30);
jQuery(".wpp_pagination_slider", this_parent).css('width', slider_width);
jQuery('.wpp_pagination_slider .ui-slider-handle', this).append('<div class="slider_page_info"><div class="val">1</div><div class="arrow"></div></div>');
});
wpp_pagination_<?php echo $unique_hash; ?> = true;
}
<?php } ?>
});
</script>
<?php
$js_result = ob_get_contents();
ob_end_clean();
ob_start(); ?>
<div class="properties_pagination <?php echo $settings['class']; ?> wpp_slider_pagination" id="properties_pagination_<?php echo $unique_hash; ?>">
<div class="wpp_pagination_slider_status">
<?php
if(function_exists('WPPFL_getNumberOfFavorites')) {
$num_of_favorites = WPPFL_getNumberOfFavorites();
} else{
$num_of_favorites = 0;
}
$currentTemplate = "";
if (isset($wpp_query['template'])) {
$currentTemplate = $wpp_query['template'];
}
?>
<?php if ($currentTemplate==TEMPLATEPATH . "/list-my-property-content.php") { ?>
<div class="wppcs-sub-menu">
<?php global $post;
$post_name = $post->post_name; ?>
<?php $class='class="active"'; ?>
<ul>
<li <?php if($post_name == 'list-my-property') { echo $class; } ?>>
<a href="<?php echo get_bloginfo('url'); ?>/list-my-property/">
View Listed Properties
</a>
</li>
<li <?php if($post_name == 'add-new-property') { echo $class; } ?>>
<a href="<?php echo get_bloginfo('url'); ?>/list-my-property/add-new-property/">
Add New Property
</a>
</li>
</ul>
</div>
<?php } else { ?>
<ul class="top_part">
<li><a>Search results</a></li>
<li class="favor">My Favourites(<span class="number_of_favorites"><?php echo $num_of_favorites; ?></span>)</li>
</ul>
<?php } ?>
<div class="clear"></div>
</div>
<?php if($use_pagination) { ?>
<div class="wpp_pagination_slider_wrapper">
<div class="wpp_page_numbers_block">
<span class="numbers-title">Pages</span>
<?php
if ($pages < 10) {
for($i=1; $i<=$pages; $i++) {
echo '<span class="page_numbers" data-value="'.$i.'">'.$i.'</span>';
}
} else {
for($i=1; $i<=$pages; $i++) {
if (($i < 4) || ($i>$pages-3)) {
echo '<span class="page_numbers" data-value="'.$i.'">'.$i.'</span>';
}
if ($i==4) {
echo '<span class="middle-pages"><span class="dotted-separator">...</span></span>';
}
}
}?>
</div>
<div class="wpp_pagination_back wpp_pagination_button"><?php _e('Prev', 'wpp'); ?></div>
<div class="wpp_pagination_forward wpp_pagination_button"><?php _e('Next', 'wpp'); ?></div>
<div class="wpp_pagination_slider"></div>
</div>
<?php } ?>
</div>
<div class="ajax_loader"></div>
<?php
$html_result = ob_get_contents();
ob_end_clean();
Thank you in anticaption.
The first thing which can cause your issue is some of third party plugins or your theme. So try firstly to deactivate third party plugins and switch theme to default one to be sure that issue doesn't relate to any of them.
Such request you can also send here
https://wordpress.org/support/plugin/wp-property
or on our site
https://usabilitydynamics.com/contact-us/
Regards.
Usability Dynamics Support
Currently using this to check the permissions of a user, If the user is logged in then it shows the file and lists the DIR. This works fine along with the login screen showing up if the user is not shown to be logged in.
I need it to be that if the product is not owned by the user (i.e. the permission is not level 3) then it will automatically link them to the brochure. I had a header setup to send the user but it does not function as I want it to.
Now what it does is loads the page but does not pass on the DIV (hence the name to check on the f12 debug to see if it had passed)
What am I missing?
p.s. the PHP logs show no errors
-- Update --
Gone through and commented out sections to see if the IF statement was attached to wrong thing, currently nothing still getting same problem
<?php
if (!securePage($_SERVER['PHP_SELF'])){die();}
$parts = parse_url($_SERVER["REQUEST_URI"]);
$page_name = basename($parts['path']);
//Links for logged in user
if(isUserLoggedIn()) {
//Links for permission level 3 (BOF)
if ($loggedInUser->checkPermission(array(3))){
if ($handle = opendir('CD500/')) {
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..'){
$thelist .= '<a href="/CD500/'.$file.'" target="_blank" >'.$file.'</a></br>';
}
}
closedir($handle);
echo "
<div id='output'>
List of help files:</div>
<div id='List'>
$thelist ";
}
else {
echo " asdfasdfasdfadf ";
}
}
?>
<div id='default'>
<?php } else { ?>
<li><a class="<?php echo ($page_name=='login.php')?'selected':'';?>" href="login.php">Login</a></li>
<li><a class="<?php echo ($page_name=='register.php')?'selected':'';?>" href="register.php">Register</a></li>
<li><a class="<?php echo ($page_name=='forgot-password.php')?'selected':'';?>" href="forgot-password.php">Forgot Password</a></li>
<?php } ?></div>
The problem lies at your else clause not belonging to your first if statement where you check for user login. I have also changed the code a bit at the point where you need to conditionally print some html. Try the following.
<?php
if (!securePage($_SERVER['PHP_SELF'])){die();}
$parts = parse_url($_SERVER["REQUEST_URI"]);
$page_name = basename($parts['path']);
//Links for logged in user
if(isUserLoggedIn()) {
//Links for permission level 3 (BOF)
if ($loggedInUser->checkPermission(array(3))){
if ($handle = opendir('CD500/')) {
while (false !== ($file = readdir($handle))){
if ($file != '.' && $file != '..'){
$thelist .= '<a href="/CD500/'.$file.'" target="_blank" >'.$file.'</a></br>';
}
}
closedir($handle); ?>
<?php if($thelist): ?>
<div id='output'>
List of help files:
</div>
<div id='List'>
<?php echo $thelist; ?>
</div>
<?php endif; ?>
<?php }
} else {
header( 'Location: http://www.yoursite.com/new_page.html' ) ;
}
} else { ?>
<div>
<li><a class="<?php echo ($page_name=='login.php')?'selected':'';?>" href="login.php">Login</a></li>
<li><a class="<?php echo ($page_name=='register.php')?'selected':'';?>" href="register.php">Register</a></li>
<li><a class="<?php echo ($page_name=='forgot-password.php')?'selected':'';?>" href="forgot-password.php">Forgot Password</a></li>
</div>
<?php } ?>
I am working on a webpage, where I plan to have to two menu tabs for one of the tabs on the Main-menu tab. I am able to get the Sub-menu tabs to show up on the page. The content gets populated properly for all the tabs. But, I am not able to navigate between the tabs. I am posting the code below of how I declared the tabs:
Header.php
<div class="row clearfix">
<div class="col-md-12 column">
<div class="tabbable boxed parentTabs" id="mainmenutab">
<ul class="nav nav-tabs">
<?php include "mainmenu_links.php"; ?>
<li class="dropdown" onclick="dropdownuserlogin()">
<?php include "userlogin.php"; ?>
</li>
</ul>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.js"></script>
<script>
function dropdownuserlogin(e){
$('.dropdown-toggle').dropdown();
$('#userlogin').dropdown('toggle');
}
$("ul.nav-tabs a").click(function (e) {
e.preventDefault();
$(this).tab('show').addClass('active');
});
</script>
</body>
</html>
mainmenu_links.php:
<?php
$main = $_GET['main']; $sub = $_GET['sub']; /*echo $main; echo $sub;*/
$main_menu=array("Home"=>"files/home_page.php?main=1&sub=1",
"Submit a New Project"=>"files/form_page.php?main=2&sub=2",
"All Projects"=>"myday/.view_table.php?main=3&sub=1",
"Innovations"=>"files/ideafactory.php?main=4&sub=4",
"Share your learning"=>"files/shareyourlearning.php?main=5&sub=5",
"Meet the Team"=>"files/team.php?main=6&sub=6");
$i = 1;
foreach($main_menu as $key => $value){
if($i == "1"){
echo "<li class=\"active\"><a href=\"../".$value."\"";
if($main == "1" | $main==null){
echo " class=\"selected\"";
}
echo ">".$key."</a></li>";
}
else{
echo "<li><a href=\"../".$value."\"";
if($main == $i){
echo " class=\"selected\"";
}
echo ">".$key."</a></li>";
$i++;
}
}
?>
projects_menulinks.php
<?php
$main = $_GET['main']; $sub = $_GET['sub'];
$sub_menu=array("Myday"=>"myday/.view_table.php?main=3&sub=1",
"Techpulse"=>"techpulse/.view_table.php?main=3&sub=2",
"BrownBag Sessions"=>"brownbag/.view_table.php?main=3&sub=3");
$i = 1;
foreach($sub_menu as $key => $value){
if($sub == "1"){
echo "<li class=\"active\"><a href=\"../".$value."\"";
echo ">".$key."</a></li>";
}
else{
echo "<li><a href=\"../".$value."\"";
echo ">".$key."</a></li>";
}
}
?>
I think I am messing up something with the tabs declaration. Can someone please let me know what am I doing wrong.