Test Drive & A Few Little Questions

Ask for help or provide support to other members.
OneManLaptop
Posts: 15
Joined: Tue Mar 16, 2021 3:29 pm

Re: Test Drive & A Few Little Questions

Post by OneManLaptop »

It's a pleasure and I'm happy for our little studio to be recognised as a supporter. :)

I'll do my best to spread the word. I think WCMS holds real appeal for bespoke designers who want a CMS system which is basically invisible to the design process. I've already previewed the CMS to two of my clients and they're thrilled. Right now they're having to use Cushy CMS which abstracts the content away from the design, but when I showed them that they can now edit the text on the website itself, it's just so much more straight forward for them and they don't need any long explanations, they instantly get it and start editing straight away.

Anyhoo, as you say onward and upward, happy to be along for the journey. :)
User avatar
wiz
Admin
Posts: 568
Joined: Sat Oct 30, 2010 12:23 am

Re: Test Drive & A Few Little Questions

Post by wiz »

Honored to have such supporters along the way.

Hoping the upcoming versions will be even more seamless (such as the Summernote editor/or other editors ability to not enable users to do too much of a mess with uploading files).

Really appreciate your feedback - cheers to slow and steady growth and awesome partnerships. :)
OneManLaptop
Posts: 15
Joined: Tue Mar 16, 2021 3:29 pm

Re: Test Drive & A Few Little Questions

Post by OneManLaptop »

Hey Wiz, just a quick question. I'm afraid I'm going to betray my lack of PHP experience here, but I can't figure out why these bits of code don't work:

Code: Select all

<?php if ($Wcms->loggedIn === true) { $Wcms->js(); } ?>

Code: Select all

<?php if ($Wcms->loggedIn === true) { echo("<link rel='stylesheet' rel='preload' as='style' href='$Wcms->asset('css/style.css') '>"); } ?>
You can see what I'm trying to do, would you mind showing me how I should be writing that out... thank you kindly. 8-)
User avatar
wiz
Admin
Posts: 568
Joined: Sat Oct 30, 2010 12:23 am

Re: Test Drive & A Few Little Questions

Post by wiz »

Hey OneManLaptop, hope you're doing amazing!

Absolutely, this should work:

Code: Select all

<?php
    if ($Wcms->loggedIn === true) {
        echo $Wcms->js();
    }
?>
and for your second example

Code: Select all

<?php
    if ($Wcms->loggedIn === true) {
        echo "<link rel='stylesheet' rel='preload' as='style' href='$Wcms->asset('css/style.css') '>";
    }
?>
Note: when echoing the above, you don't need the "()" after echo.
Here's an example of the incorrect usage (formatted)

Code: Select all


<?php
    // Non working example
    if ($Wcms->loggedIn === true) {
        echo ("<link rel='stylesheet' rel='preload' as='style' href='$Wcms->asset('css/style.css') '>");
    }
?>
Hope this helps, let me know how it works out for you :)
OneManLaptop
Posts: 15
Joined: Tue Mar 16, 2021 3:29 pm

Re: Test Drive & A Few Little Questions

Post by OneManLaptop »

Brilliant, thanks a lot bud. Slight change to the CSS one and it all worked a treat:

Code: Select all

<?php echo "<link rel='stylesheet' rel='preload' as='style' href='".$Wcms->asset('css/style.css')." '>"; ?>
Thankfully my other projects have been rubber stamped so I'm really optimistic about having my first Wonder CMS project finished before the end of the month. :D
User avatar
wiz
Admin
Posts: 568
Joined: Sat Oct 30, 2010 12:23 am

Re: Test Drive & A Few Little Questions

Post by wiz »

No worries at all, glad to help if time permits.
If you run into any other hiccups, feel free to post back and we can make your deadline a reality. :)
OneManLaptop
Posts: 15
Joined: Tue Mar 16, 2021 3:29 pm

Re: Test Drive & A Few Little Questions

Post by OneManLaptop »

Brilliant, thanks.

As you can tell, this is my main project right now so sorry to keep bothering you, I really don't take your time or help for granted so thanks for whatever time you can spare, there's absolutely no obligation on your part as I'm probably going to be a bit of edge case in some of my uses of WCMS, so when there's no easy answer, just let me know and I'll either work around the problem or find another way of doing things.

So today's problem, haha. The site I'm working on isn't really multi-lingual, but it does have two language specific pages and it would be really handy if I could just set the language of these files. So here's what I thought would work:

I've added this to each page in the database:

Code: Select all

"lang": "en",
Then I've tried to call it in the theme page with this:

Code: Select all

<?= $Wcms->page('lang') ?>
Alas, nothing is being written. I've had a peek in the index file to see if there's anything there I need to edit, but that's obviously a risky strategy as it will get overwritten with the next update. I tried:

Code: Select all

<?= $Wcms->get('config', 'lang') ?>
That works, but swapping config for page doesn't, which is obviously the functionality I need.

So that's one down!

The next problem. I'm trying to check what the page id is, so that I can write an extra little bit of functionality. It's nothing more than adding a "current" class to the custom nav I've written. So I tried this on one of the links:

Code: Select all

<?= if ($Wcms->page('title') === "events") print "current" ?>
Which causes the site to crawl away screaming at the unhealthy shapes I'm trying to bend it into... and so here I am... again.

Once I get on top of those two I'm really on the verge of tying this all up. The final step will be to get the pages to recognise my custom language files. I originally had a config.php file with this in it:

I'm basically converting a website which uses PHP switch to load pages, so my setup looked something like this:

Code: Select all

$id = isset($_GET['id']) ? $_GET['id'] : '';
$id=str_replace("/","",$id);

switch($id) {
		
	default://only added to default page
	case "English":
	$thisPage = "English";
	$title = "English Website";
	$desc = "Our English Website.";
	$lang_file = 'lang.en.php';
  	$langName = 'en';
	$page = "pages/en/$thisPage.php";
	break;
	
	case "Dutch":
	$thisPage = "Dutch";
	$title = "Dutch Website";
	$desc = "Our Dutch Website.";
	$lang_file = 'lang.nl.php';
  	$langName = 'nl';
	$page = "pages/nl/$thisPage.php";
	break;
	
	case "French":
	$thisPage = "French";
	$title = "French Website";
	$desc = "Our French Website.";
	$lang_file = 'lang.fr.php';
  	$langName = 'fr';
	$page = "pages/fr/$thisPage.php";
	break;

}

include_once 'languages/'.$lang_file;

?>
Then I would call the correct languages loaded from the language files like this:

Code: Select all

<?php echo $lang['PAGETITLE']; ?>
Right now, I'm unsure how to convert this method to something WCMS friendly, so any pointers you can offer would be much appreciated.

As I say, I hope I'm not becoming a nuisance. As and when you have the time to help, then it's much appreciated but only when you have the time available. I really do plan to build a kick ass template for WCMS when I'm done though. :) Thanks again and as far as I can tell, I'm nearly, nearly done!
User avatar
wiz
Admin
Posts: 568
Joined: Sat Oct 30, 2010 12:23 am

Re: Test Drive & A Few Little Questions

Post by wiz »

Glad to help out, no nuisance here :)

There's a little hackier/easier way of setting different languages for the html in the beginning of your document.

Code: Select all

<!-- Custom html lang for specific pages -->
<?php
    if ($Wcms->currentPage == 'yourPage1' || $Wcms->currentPage == 'yourPage12 ) {
        echo "<html lang="en">";
    } else {
        echo "<html lang="en">";
    }
?>
 
With your example, please note that when using

Code: Select all

<?= $Wcms->get('config', 'lang') ?>
This calls the lang parameters from the config part of the database (where we also save the password), not inside the pages.

If you save the "lang" parameter in each one of your pages (database), then this should call it correctly

Code: Select all

<?= $Wcms->page('lang') ?>

In regards to adding "current" for active pages, note that WonderCMS should already add the class "active" in the page you're already visiting.
If you'd like to hardcode your menu, something like this works:

Code: Select all

<nav>
    <ul>
        <li class="<?php if ( $Wcms->currentPage == '/' || $Wcms->currentPage == 'home') : ?> active<?php endif ?>">
            <a href="/" title="Home">
            Home
            </a>
        </li>
        <li class="<?php if ( $Wcms->currentPage == 'about') : ?> active<?php endif ?>">
            <a href="/about" title="About">
            About
            </a>
        </li>
    </ul>
</nav>
In regards to the last part, I don't fully understand what you're trying to do, and creating a plugin for this might be easier, if I understand it correctly. But first, let's make the above work, as you expect it to, and then move onwards.

How has your project been progressing?
Post Reply