[Theme] Simple Red - Version 0.2

Post Reply
bpsysgamer
Posts: 3
Joined: Wed Jan 04, 2017 5:18 pm

[Theme] Simple Red - Version 0.2

Post by bpsysgamer »

Image

Hello friends, here I leave my first design for this CMS, in this case it is very simple but nice

*Contains an easy to use advertising system

Image

Installation:
  • Move the folder "redtheme" to the folder "themes"
Download:
redtheme-0.2.zip
(21.73 KiB) Downloaded 556 times
Last edited by bpsysgamer on Sat Jan 07, 2017 2:13 pm, edited 1 time in total.
User avatar
wiz
Posts: 749
Joined: Sat Oct 30, 2010 12:23 am

Re: [Theme]Simple Red - Version 0.1

Post by wiz »

Hello bpsysgamer, and welcome to the community!

Thank you for your contribution, but there is currently one issue with your theme - index.php should never not be changed, as WonderCMS rewrites it when updating. Please use the functions.php file (as described here) to include any extra functions, so the users will be able to update their index.php normally - through our one click updater.

Thanks again and welcome!
bpsysgamer
Posts: 3
Joined: Wed Jan 04, 2017 5:18 pm

Re: [Theme]Simple Red - Version 0.1

Post by bpsysgamer »

wiz wrote:Hello bpsysgamer, and welcome to the community!

Thank you for your contribution, but there is currently one issue with your theme - index.php should never not be changed, as WonderCMS rewrites it when updating. Please use the functions.php file (as described here) to include any extra functions, so the users will be able to update their index.php normally - through our one click updater.

Thanks again and welcome!
How do we edit the menu from that file?
yassineaddi
Posts: 10
Joined: Wed Nov 09, 2016 2:10 pm

Re: [Theme]Simple Red - Version 0.1

Post by yassineaddi »

Hi bpsysgamer,

As wiz said, the index.php is the core of this tiny yet powerful Content Management System, so, for the reason he mentioned, users should avoid modifying it unless they want to use WonderCMS as a skeleton for their projects or they're not interested in receiving updates and/or upgrades and/or plugins...etc

After we've clarify that, to modify the navigation function, we can use the built-in plugin system - as you know WonderCMS is pluggable - to override/rewrite the navigation output. Here is a simple solution I've come out with:

In the functions.php, add the following code:

Code: Select all

wCMS::addListener('navigation', 'overrideNavigation');

function overrideNavigation ($args) {
    $output = '';
    foreach (wCMS::getConfig('menuItems') as $item) {
        $output .= '<li class="nav-item"><a '.((mb_strtolower($item) == wCMS::$currentPage) ? ' class="active nav-link"' : '').'class="nav-link text-inverse" href="'.wCMS::url(wCMS::getSlug($item)).'">'.$item.'</a></li>';
    }
    $args[0] = $output;

    return $args;
}
So that the final functions.php is gonna be:

Code: Select all

<?php

wCMS::addListener('navigation', 'overrideNavigation');

function overrideNavigation ($args) {
    $output = '';
    foreach (wCMS::getConfig('menuItems') as $item) {
        $output .= '<li class="nav-item"><a '.((mb_strtolower($item) == wCMS::$currentPage) ? ' class="active nav-link"' : '').'class="nav-link text-inverse" href="'.wCMS::url(wCMS::getSlug($item)).'">'.$item.'</a></li>';
    }
    $args[0] = $output;

    return $args;
}

function AdvertisingArea() {
    // Check if the AdvertisingArea area is already exists, if not, create it.
    if (wCMS::getConfig('AdvertisingArea') === false) {
        wCMS::setConfig('AdvertisingArea', '<a href="https://join-adf.ly/252596"><img border="0" src="https://cdn.adf.ly/images/banners/adfly.160x600.4.gif" width="160" height="600" title="AdF.ly - acorta links y gana dinero!" /></a>');
    }

    // Fetch the value of AdvertisingArea from the database.
    $value = wCMS::getConfig('AdvertisingArea');
    // If value is empty, let's put something in it by default. (IMPORTANT)
    if (empty($value)) {
        $value = 'Empty content.';
    }
    // It's necessary to pass the editable method to the fetched value/content
    // to make the area editable ONLY if admin is logged in.
    if (wCMS::$loggedIn) {
        // If logged in, it must be editable
        return wCMS::editable('AdvertisingArea', $value);
    }
    // If not logged in, don't make it editable!
    return $value;
}
?>
There is more than one way to achieve your goal, just be creative! and that's the point of using WonderCMS, creating challenging problems, work hard to fix them, be a better developer!

Thank you once again for your valuable contribution, we're going to approve your theme.

Kind regards,
Yassine.
bpsysgamer
Posts: 3
Joined: Wed Jan 04, 2017 5:18 pm

Re: [Theme]Simple Red - Version 0.2

Post by bpsysgamer »

Many thanks for your help, new version, there is nothing to edit the file "index.php" :D
User avatar
wiz
Posts: 749
Joined: Sat Oct 30, 2010 12:23 am

Re: [Theme]Simple Red - Version 0.2

Post by wiz »

bpsygamer, great job. After further inspection, we've noticed you've included an referral link which is not editable unless the users edits the functions.php file.

To get this theme into the approved section, we will have to require to make this URL editable through the theme/settings itself - you can use functions.php for this. Another option is to remove the link completely and move it into the footer like -> Theme created by "YourName" - YourName can be your affiliate link for the ad.fly.

Everything else seems to be perfect.
Post Reply