/    Sign up×
Community /Pin to ProfileBookmark

Increment oprator and layout of webpage

Hello all,

This is my first post because after looking at a bunch of reference books and searching online I cannot find or figure out a solution. Our grade 6-12 school is running Moodle open source courseware. The one format for the course lays out sections speciifed by the teacher on one page. If I choose to show 10 sections on my page it will place 1-10 under each other and then scroll the page vertically. Each section has the ability to add and edit text, activities, resources. Here is what I have been trying to do. I have been trying to put the output into a tabbed layout on the page, just like a form that is too long and you break it into chunks (tabs). What happens is my teachers put in a half of years worth of topics and the page scrolls forever.

The issue I have is that the code is using an increment operator to show the topics and all the code I have seen is for hard coded text when doing a tabbed page layout. Below is the significant code dealing with the sections. I am not sure if I need javascript here, php or a combination.

[code=php]
/// Now all the normal modules by topic
/// Everything below uses “section” terminology – each “section” is a topic.

$timenow = time();
$section = 1;
$sectionmenu = array();

while ($section <= $course->numsections) {

if (!empty($sections[$section])) {
$thissection = $sections[$section];

} else {
unset($thissection);
$thissection->course = $course->id; // Create a new section structure
$thissection->section = $section;
$thissection->summary = ”;
$thissection->visible = 1;
if (!$thissection->id = insert_record(‘course_sections’, $thissection)) {
notify(‘Error inserting new topic!’);
}
}

$showsection = (isteacher($course->id) or $thissection->visible or !$course->hiddensections);

if (!empty($displaysection) and $displaysection != $section) {
if ($showsection) {
$strsummary = strip_tags(format_string($thissection->summary,true));
if (strlen($strsummary) < 57) {
$strsummary = ‘ – ‘.$strsummary;
} else {
$strsummary = ‘ – ‘.substr($strsummary, 0, 60).’…’;
}
$sectionmenu[‘topic=’.$section] = s($section.$strsummary);
}
$section++;
continue;
}

if ($showsection) {

$currenttopic = ($course->marker == $section);

if (!$thissection->visible) {
$sectionstyle = ‘ hidden’;
} else if ($currenttopic) {
$sectionstyle = ‘ current’;
} else {
$sectionstyle = ”;
}

echo ‘<tr id=”section-‘.$section.'” class=”section main’.$sectionstyle.'”>’;

echo ‘<td class=”left side”>’;
echo ‘<a name=”‘.$section.'”>’.$section.'</a>’;
echo ‘</td>’;

echo ‘<td class=”content”>’;
if (!isteacher($course->id) and !$thissection->visible) { // Hidden for students
echo get_string(‘notavailable’);
} else {
echo ‘<div class=”summary”>’;
$summaryformatoptions->noclean = true;
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);

if (isediting($course->id)) {
echo ‘ <a title=”‘.$streditsummary.'” href=”editsection.php?id=’.$thissection->id.'”>’.
‘<img src=”‘.$CFG->pixpath.’/t/edit.gif” border=”0″ height=”11″ width=”11″ alt=”” /></a><br /><br />’;
}
echo ‘</div>’;

print_section($course, $thissection, $mods, $modnamesused);

if (isediting($course->id)) {
print_section_add_menus($course, $section, $modnames);
}
}
echo ‘</td>’;

echo ‘<td class=”right side”>’;
if ($displaysection == $section) { // Show the zoom boxes
echo ‘<a href=”view.php?id=’.$course->id.’&amp;topic=all#’.$section.'” title=”‘.$strshowalltopics.'”>’.
‘<img src=”‘.$CFG->pixpath.’/i/all.gif” height=”25″ width=”16″ border=”0″ /></a><br />’;
} else {
$strshowonlytopic = get_string(‘showonlytopic’, ”, $section);
echo ‘<a href=”view.php?id=’.$course->id.’&amp;topic=’.$section.'” title=”‘.$strshowonlytopic.'”>’.
‘<img src=”‘.$CFG->pixpath.’/i/one.gif” height=”16″ width=”16″ border=”0″ alt=”” /></a><br />’;
}

if (isediting($course->id)) {
if ($course->marker == $section) { // Show the “light globe” on/off
echo ‘<a href=”view.php?id=’.$course->id.’&amp;marker=0&amp;sesskey=’.$USER->sesskey.’#’.$section.'” title=”‘.$strmarkedthistopic.'”>’.
‘<img src=”‘.$CFG->pixpath.’/i/marked.gif” vspace=”3″ height=”16″ width=”16″ border=”0″ alt=”” /></a><br />’;
} else {
echo ‘<a href=”view.php?id=’.$course->id.’&amp;marker=’.$section.’&amp;sesskey=’.$USER->sesskey.’#’.$section.'” title=”‘.$strmarkthistopic.'”>’.
‘<img src=”‘.$CFG->pixpath.’/i/marker.gif” vspace=”3″ height=”16″ width=”16″ border=”0″ alt=”” /></a><br />’;
}

if ($thissection->visible) { // Show the hide/show eye
echo ‘<a href=”view.php?id=’.$course->id.’&amp;hide=’.$section.’&amp;sesskey=’.$USER->sesskey.’#’.$section.'” title=”‘.$strtopichide.'”>’.
‘<img src=”‘.$CFG->pixpath.’/i/hide.gif” vspace=”3″ height=”16″ width=”16″ border=”0″ alt=”” /></a><br />’;
} else {
echo ‘<a href=”view.php?id=’.$course->id.’&amp;show=’.$section.’&amp;sesskey=’.$USER->sesskey.’#’.$section.'” title=”‘.$strtopichide.'”>’.
‘<img src=”‘.$CFG->pixpath.’/i/show.gif” vspace=”3″ height=”16″ width=”16″ border=”0″ alt=”” /></a><br />’;
}

if ($section > 1) { // Add a arrow to move section up
echo ‘<a href=”view.php?id=’.$course->id.’&amp;section=’.$section.’&amp;move=-1&amp;sesskey=’.$USER->sesskey.’#’.($section-1).'” title=”‘.$strmoveup.'”>’.
‘<img src=”‘.$CFG->pixpath.’/t/up.gif” vspace=”3″ height=”11″ width=”11″ border=”0″ alt=”” /></a><br />’;
}

if ($section < $course->numsections) { // Add a arrow to move section down
echo ‘<a href=”view.php?id=’.$course->id.’&amp;section=’.$section.’&amp;move=1&amp;sesskey=’.$USER->sesskey.’#’.($section+1).'” title=”‘.$strmovedown.'”>’.
‘<img src=”‘.$CFG->pixpath.’/t/down.gif” vspace=”3″ height=”11″ width=”11″ border=”0″ alt=”” /></a><br />’;
}

}

echo ‘</td></tr>’;
echo ‘<tr class=”section separator”><td colspan=”3″ class=”spacer”></td></tr>’;
}

$section++;
}
[/code]

Thank you for any help,

Deon

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @deonteach spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...