Adding Sidebar In CSWeb

Discussions about syncing data via Bluetooth, Dropbox, FTP, and using CSWeb
Forum rules
New release: CSPro 8.0
Post Reply
mikatot
Posts: 3
Joined: March 23rd, 2018, 11:03 pm

Adding Sidebar In CSWeb

Post by mikatot »

Hi. I am a little familiar with CSPro and some knowledge in PHP. I know that it is possible to have additional menu in the sidebar but Twig is new to me and I can't seem to find the pages that I need to configure or change in order to add one.
What I have tried so far is adding just one menu:

Code: Select all

 <li>
    <a href="{{ path('maps') }}"> Maps</a>
</li>
I have added this in the app.php

Code: Select all

$app->mount('/maps',new \Controllers\MapController());
I have added the MapController in the
/src/ui/Controllers/
. But, I am getting the "Whoops, looks like something went wrong." message. I can't also seem to find anything in any routes.php files. What files do I need to change/configure to add a working sidebar menu. Thanks much.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Adding Sidebar In CSWeb

Post by josh »

Not sure what is wrong. The mount line looks correct. You also need to add the corresponding controller in src/ui/src/Controllers/MapController.php.

While doing development you should turn on debug so that you can see full error messages instead of "something went wrong". To do this in the file src/ui/src/app.php change:

$app['debug']=false;

to

$app['debug']=true;

Don't forget to change it back when deploying the application for production.
mikatot
Posts: 3
Joined: March 23rd, 2018, 11:03 pm

Re: Adding Sidebar In CSWeb

Post by mikatot »

Sir Josh,

I did add the MapController.php in src/ui/src/Controllers/. I am literally lost where does the path being declared. Like, it has this whole code :

Code: Select all

<div class="sidebar-nav navbar-collapse">
    <ul class="nav" id="side-menu">
        <li>
			<a href="{{ path('dashboard') }}"><i class="fa fa-database fa-fw"></i> Data</a>
        </li>
        <li>
			<a href="{{ path('apps') }}"><i class="fa fa-desktop fa-fw"></i> Apps</a>
        </li>
        <li>
			<a href="{{ path('users') }}"><i class="fa fa-users fa-fw"></i> Users</a>
        </li>
        <li>
            <a href="{{ path('maps') }}"> Maps</a>
        </li>
    </ul>
</div>
But when I add the maps, its not working anymore. Where does the path being declared? I know that this line is giving the error

Code: Select all

 <a href="{{ path('maps') }}"> Maps</a>
because removing the whole line or just the href link makes it run normally.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Adding Sidebar In CSWeb

Post by josh »

Path is some internal magic symfony framework stuff that gets the relative url. Basically it lets you generate a link that is relative to the current page. You can read more here: https://symfony.com/doc/current/referen ... .html#path

You may read some tutorials on Symfony framework to get started. It is a bit different than standard PHP and it is the basis of the CSWeb UI. Fortunately there is lots of info online.

When you turn on debug in app.php you should see more info from the error that will figure out what the problem is. It is likely a syntax in some file but without debugging on you won't be able to tell since it will just tell "something went wrong" for every error.
savy
Posts: 159
Joined: December 27th, 2012, 1:36 pm

Re: Adding Sidebar In CSWeb

Post by savy »

If you see the DictionaryController class, the connect function adds the routes and binds it to the function that is called.
Also, in the /api/index.php make sure that the authentication for your route is set, see the lines after 129 that adds the endpoint authentication using oauth.
mikatot
Posts: 3
Joined: March 23rd, 2018, 11:03 pm

Re: Adding Sidebar In CSWeb

Post by mikatot »

Sir @savy, thanks, that help a lot.
Post Reply