Adding activity in a section in Moodle - not saving the section - php

So I've been looking for 2 days into this problem, I can't find either where the code exists, or how to edit/fix it.
What is happening is that when you click "Add Activity or Resource" while editing a course, it adds the activity or resource, but always into section 0. It doesn't save which section I've clicked from, and when the redirect to course/modedit.php happens, the URL shows section=0, no matter if from section 1 or 10. Further to this, moving the activity into other sections also does not save - it simply re-orders the activity to the last one in section 0.
I am unsure as to which code is causing this issue. I need some help or guidance on where to look to begin debugging and fixing this.
I also can't be sure when this issue first appeared, as I have modified a few files in between while developing this site. The only one that may be relevant (from what I can surmise), and may help give some clue for anyone better informed than I is the following:
protected function section_header($section, $course, $onsectionpage, $sectionreturn=null) {
global $PAGE;
$o = '';
$currenttext = '';
$sectionstyle = '';
if ($section->section != 0) {
// Only in the non-general sections.
if (!$section->visible) {
$sectionstyle = ' hidden';
} else if (course_get_format($course)->is_section_current($section)) {
$sectionstyle = ' current';
}
}
$o.= html_writer::start_tag('li', array('class' => 'section main'.$sectionstyle));
// Create a span that contains the section title to be used to create the keyboard section move menu.
$o .= html_writer::tag('span', $this->section_title($section, $course), array('class' => 'hidden sectionname'));
$leftcontent = $this->section_left_content($section, $course, $onsectionpage);
$o.= html_writer::tag('div', $leftcontent, array('class' => 'left side'));
$rightcontent = $this->section_right_content($section, $course, $onsectionpage);
$o.= html_writer::tag('div', $rightcontent, array('class' => 'right side'));
$sectionname = html_writer::tag('span', $this->section_title($section, $course));
$o.= html_writer::start_tag('a', array('href' => '#section-'.$section->section, 'class' => 'title'));
$o.= $this->output->heading($sectionname, 3, 'sectionname' . $classes);
$o.= html_writer::end_tag('a');
$o.= html_writer::start_tag('div', array('id' => 'section-'.$section->section, 'class' => 'content'));
// When not on a section page, we display the section titles except the general section if null
$hasnamenotsecpg = (!$onsectionpage && ($section->section != 0 || !is_null($section->name)));
// When on a section page, we only display the general section title, if title is not the default one
$hasnamesecpg = ($onsectionpage && ($section->section == 0 && !is_null($section->name)));
$classes = ' accesshide';
if ($hasnamenotsecpg || $hasnamesecpg) {
$classes = '';
}
$o.= html_writer::start_tag('div', array('class' => 'summary'));
$o.= $this->format_summary_text($section);
$context = context_course::instance($course->id);
$o .= $this->section_availability_message($section, has_capability('moodle/course:viewhiddensections', $context));
return $o;
}
That is my rework of the layout - allowing for a simple Jquery accordian to show/hide the sections. The Jquery is:
$(document).ready(function() {
function close_accordion_section() {
$(".topics .title").removeClass("active");
$(".topics .content").slideUp(300).removeClass("open");
$("#section-0").stop();
}
$(".title").click(function(e) {
// Grab current anchor value
var currentAttrValue = $(this).attr("href");
if($(e.target).is(".active")) {
close_accordion_section();
}else {
close_accordion_section();
// Add active class to section title
$(this).addClass("active");
// Open up the hidden content panel
$(".topics " + currentAttrValue).slideDown(300).addClass("open");
}
e.preventDefault();
});
});
I have edited nothing else in relation to the course page, but that doesn't mean the issue might not be elsewhere.
Sorry for the wall of text, but please could someone help me find why the Activity isn't adding to the right section, nor allowing me to move into the right section afterwards? I'd really appreciate it.

Related

Change CSS classes in WooCommerce Theme

in my home Page there is a list item
<ul class="nm-products products xsmall-block-grid-1 small-block-grid-2 medium-block-grid-3 large-block-grid-6 grid-default layout-static-buttons attributes-position-thumbnail has-action-links">
I Want to change xsmall-block-grid-1 TO xsmall-block-grid-2 for small screens.
I looked into the functions.php and found this:
// Categories layout classes
$categories_class = ' toggle-' . $nm_theme_options['blog_categories_toggle'];
if ( $nm_theme_options['blog_categories_layout'] === 'columns' ) {
$column_small = ( intval( $nm_theme_options['blog_categories_columns'] ) > 4 ) ? '3' : '2';
$categories_ul_class = 'columns small-block-grid-' . $column_small . ' medium-block-grid-' . $nm_theme_options['blog_categories_columns'];
} else {
$categories_ul_class = $nm_theme_options['blog_categories_layout'];
}
But i don't see how to I can edit TO Xsmall bloc grid.
I tried to chande the inside the .xsmall-block-grid-1{} class in the grid.css file but it didn't worK.
I don't know if it's allowed to give you the link to my website so to you can inspect.

Hide main-component class in homepage

I have a template that has the feature to hide front-page component.
Unfortunately setting this feature to "hide" does hide the component but not the wrapper that surrounds it so, i need help to hide it manually in the home page only with id '101'.
The code that uses that feature is below:
function setMainContent() {
global $mainbody_block, $editmode, $side_block, $subnav, $active, $splitmenu_col, $leftcolumn_width, $rightcolumn_width, $mainmod2_width, $frontpage_component, $mainmod3_width;
$row = 'section-row3';
$cases = array(
'case3' => modulesClasses('case3'),
'case4' => modulesClasses('case4')
);
$this->maincontent = '<div id="section-row3" class="section-row"><div id="section-row3-inner">
<div id="main-body-surround" class="spacer">';
function mainbody($t, $c) {
global $mainbody_block, $leftcolumn_width, $mainmod2_width, $editmode, $frontpage_component, $mainmod3_width, $leftcolumn_width, $splitmenu_col, $subnav, $active;
$tmp = "";
$tmp .= '<div id="main-body" class="spacing">
<div class="module-'.$mainbody_block.'">';
$main = '
<div id="main-content">';
Is the best way to do this with php or css?

Wordpress do_shortcode strange behavior

I am developing a WP plugin which processes shortcodes and displays amazon item data in place of them. The plugin is working as desired, except for a little strange behavior. You can see my test run at http://passivetest.themebandit.com/test-post-for-zon-plugin/ .
If you scroll down on that page, you can see that 4 "1" s are appended to the content. The shortcode is processed 4 times in this page, and each time WP is adding an undesired 1 to the output. I don't understand why this is happening. There is no "1" anywhere in my html files, and its nowhere in the post content. All my functions just return the content that is to be replaced in place of the shortcode. Can someone please give an explanation for it and let me know how to remove these? Thanks in advance..
My code is as follows:
add_shortcode('zon_product', 'zon_process_shortcode');
// Zon Shortcode processor
function zon_process_shortcode($attributes, $content = null) {
global $zon_html_path;
// default options for shortcode
$options = array('asin' => '', 'style' => 'compact', 'loc' => 'com');
extract(shortcode_atts($options, $attributes));
$asin = $attributes['asin'];
// first find asin in local zon_data table
$zdb = ZonDbHandler::instance();
$product = $zdb->findASIN($asin);
if ($product) {
// if product exists in db, render template
return zon_display_product($product, $attributes);
} else {
// product does not exist in database, get data through amazon api worflow
$product = ZonLibrary::getAmazonProduct($asin, $attributes['loc']);
if ($product) {
// product data has been successfully retrieved and saved, render template
return zon_display_product($product, $attributes);
} else {
// error in fetching product data, check amazon access key id and api secret
$content = include($zon_html_path . 'html' . DIRECTORY_SEPARATOR . 'api_error.php');
return $content;
}
}
}
// Renders selected template with product data
function zon_display_product(ZonProduct $product, $attributes) {
global $zon_html_path;
global $zon_path;
// process other shortcode options
$view_vars = array();
$view_vars['style'] = (isset($attributes['style'])) ? $attributes['style'] : "default";
$view_vars['show_price'] = (isset($attributes['show_price']) && $attributes['show_price'] == 0) ? false : true;
$view_vars['price_updates'] = (isset($attributes['price_updates']) && $attributes['price_updates'] == 0) ? false : true;
$view_vars['hide_unavailable'] = (isset($attributes['hide_unavailable']) && $attributes['hide_unavailable'] == 1) ? true : false;
$view_vars['show_desc'] = (isset($attributes['show_desc']) && $attributes['show_desc'] == 0) ? false : true;
// check if template file exists
if (!is_file($zon_html_path . 'html' . DIRECTORY_SEPARATOR . $view_vars['style'] . '.php')) {
$content = 'ERROR! Zon Template not found. Please check you are using a correct value for the "style" parameter.';
return $content;
} else {
// get product array
$product = $product->getArray();
// if product is unavailable and hide_unavailable is true, return unavailable template
if ($view_vars['hide_unavailable']) {
if ((strpos($product['availability'], "Usually") === false) && strpos($product['availability'], "ships") === false) {
$content = include($zon_html_path . 'html' . DIRECTORY_SEPARATOR . 'unavailable.php');
return $content;
}
}
// render chosen template file
$content = include($zon_html_path . 'html' . DIRECTORY_SEPARATOR . $view_vars['style'] . '.php');
return $content;
}
}

Drupal SEO page titles

I am trying to list a few games, each, on individual pages. While a game page is opened into a new window the head title of page (< title>) is set to games page header (< h1> My Game). Also to list all game types I am using quick tabs.
From 12 types of games only at 2 of them the title is settled correctly and my problem is that I don't know from where it comes. I have tried to var_dump() all the headers and all of them are returning the same thing "Game" not the title/heading from db.
Where should I look or what would be the next step ?
$metaTitle = $page['content']['metatags']['global']['title']['#attached']['metatag_set_preprocess_variable'][0][2];
$metaTitle = str_replace(' | SuperCasino.com', '', $metaTitle);
Where should I look or what would be the next step ?
Here is my preprocess page code
function desktop_preprocess_page(&$vars, $hook) {
if (isset($vars['node_title'])) {
$vars['title'] = $vars['node_title'];
}
// Adding a class to #page in wireframe mode
if (theme_get_setting('wireframe_mode')) {
$vars['classes_array'][] = 'wireframe-mode';
}
// Adding classes wether #navigation is here or not
if (!empty($vars['main_menu']) or !empty($vars['sub_menu'])) {
$vars['classes_array'][] = 'with-navigation';
}
if (!empty($vars['secondary_menu'])) {
$vars['classes_array'][] = 'with-subnav';
}
// Page template suggestions based off of content types
if (isset($vars['theme_hook_suggestions']['node'])) {
$vars['theme_hook_suggestions'][] = 'page__type__'. $vars['node']->type;
$vars['theme_hook_suggestions'][] = "page__node__" . $vars['node']->nid;
}
// Add first/last classes to node listings about to be rendered.
if (isset($vars['page']['content']['system_main']['nodes'])) {
// All nids about to be loaded (without the #sorted attribute).
$nids = element_children($vars['page']['content']['system_main']['nodes']);
// Only add first/last classes if there is more than 1 node being rendered.
if (count($nids) > 1) {
$first_nid = reset($nids);
$last_nid = end($nids);
$first_node = $vars['page']['content']['system_main']['nodes'][$first_nid]['#node'];
$first_node->classes_array = array('first');
$last_node = $vars['page']['content']['system_main']['nodes'][$last_nid]['#node'];
$last_node->classes_array = array('last');
}
}
//var_dump($vars['theme_hook_suggestions']);die();
// Page template suggestions based off URL alias
if (module_exists('path')) {
//$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
$alias = request_path();
if ($alias != $_GET['q']) {
//echo'here';die;
$template_filename = 'page';
foreach (explode('/', $alias) as $path_part) {
$template_filename = $template_filename . '__' . str_replace('-','_',$path_part);
$vars['theme_hook_suggestions'][] = $template_filename;
//var_dump($template_filename);
}
}
}
You can use drupal_set_title(YOUR_TITLE) for the different pages.
drupal_set_title($title = NULL, $output = CHECK_PLAIN)
https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_set_title/7
From the theme level, you can use this code in your template.php:
function MYTHEMENAME_preprocess_page(&$vars, $hook) {
$vars['title'] = $custom_title';
$vars['head_title'] = $custom_title;
}
For Drupal 7 its is :
$vars['site_name']

drupal 6 mini pager theming

I am trying to theme particular pagers on the site and no matter what id I try it doesn't seem to get picked up. This is what I am using to theme all pagers now.
function Subtle_Hightlights_views_mini_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9) {
global $pager_page_array, $pager_total;
// Calculate various markers within this pager piece:
// Middle is used to "center" pages around the current page.
$pager_middle = ceil($quantity / 2);
// current is the page we are currently paged to
$pager_current = $pager_page_array[$element] + 1;
// max is the maximum page number
$pager_max = $quantity;
// End of marker calculations.
$li_previous = theme('pager_previous', (isset($tags[1]) ? $tags[1] : t('')), $limit, $element, 1, $parameters);
if (empty($li_previous)) {
$li_previous = "";
}
$li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : t('')), $limit, $element, 1, $parameters);
if (empty($li_next)) {
$li_next = "";
}
if ($pager_total[$element] > 1) {
$items[] = array(
'class' => 'pager-previous-mini',
'data' => $li_previous,
);
if ($pager_current == 9){
$li_next = "";
}
$items[] = array(
'class' => 'pager-current-mini',
'data' => t('#current of #max', array('#current' => $pager_current, '#max' => $pager_max)),
);
$items[] = array(
'class' => 'pager-next-mini',
'data' => $li_next,
);
return theme('item_list', $items, NULL, 'ul', array('class' => 'pager'));
}
}
now this works to theme all mini pagers but when I try to apply the name of the view and block like this.
function Subtle_Hightlights_views_mini_pager__news_items__block_2($tags = array(), $limit = ``10, $element = 0, $parameters = array(), $quantity = 9) {
does nothing acts as though the code isnt there anymore. Anyone else tried this and it actually worked?
There is a good step by step instructions on how you can overwrite the pager (mini or full). The only step that I would suggest that you do different is when you get to list of theme function names that you can use to override your views pager inside your template.php file, just use this module: Theme developer. Once it's enabled it will provide in a much easier way the suggestions. If that fails, then just try the article's methods.
Drupal 6 Override views pager theme function

Categories