Display a message key as a page.

Use this forum to talk about Nova and ask any questions you may have about it. Please use the Help & Support forum if you have found a bug or need help getting something working.

AlPrunty Mon Jan 25, 2016 6:04 pm

Display a message key as a page.

I have went to site -> Admin Control panel -> Message & Titles

I chose the Messages tab

I created a message Tab like this...


Writing Guide
Key: writing

Now how do I make that writing key display as a page with the menu? Help

Allen

Posts: 12


AgentPhoenix Mon Jan 25, 2016 7:08 pm

Re: Display a message key as a page.

You'll need to create a new page in order to do that. The Help Center has an article about that.

http://help.anodyne-productions.com/art ... a-new-page
User avatar

Posts: 7576


AlPrunty Mon Jan 25, 2016 9:45 pm

Re: Display a message key as a page.

Phoenix... I've been over that a thousand times.

<h1 class="page-head">Awards We've Won</h1>

<p>Below is a list of all the awards we've won!</p>

<p><img src="<?php echo base_url();?>app/assets/images/award_image.jpg" /></p>


--------

Where do I put to pull the writing keyword from the SQL Database? This shows hot to set up a file in the _base directory to show an awart_image.jpg. I set up a keyword in the database system called writing how can I make it display as a menu item page?

Allen

Posts: 12


AgentPhoenix Mon Jan 25, 2016 10:25 pm

Re: Display a message key as a page.

There are a bunch of examples of how to use messages out of the database in the main controller. You first have to grab it in the controller and then make sure it's set in the data variable you pass to the content region.

Code: Select all
// In your controller method...
$data['message'] = $this->msgs->get_message('welcome_msg');

Then in your view, you'll just echo out the variable...

Code: Select all
<?php echo $message;?>
User avatar

Posts: 7576


AlPrunty Tue Jan 26, 2016 4:27 am

Re: Display a message key as a page.

AgentPhoenix wrote:There are a bunch of examples of how to use messages out of the database in the main controller. You first have to grab it in the controller and then make sure it's set in the data variable you pass to the content region.

Code: Select all
// In your controller method...
$data['message'] = $this->msgs->get_message('welcome_msg');

Then in your view, you'll just echo out the variable...

Code: Select all
<?php echo $message;?>


---

I'm not as sharp as I used to be... my apologies. I am a veteran who has suffered from a brain injury due to a bullet in the head. I'm used to having a data dictionary when I used SQL calls.

In the case that I'm using the variable writing_guide to I replace 'message' with writing_guide or 'welcome_msg' with writing guide.

My confusion is I don't know which is the variable that needs to stay or what is the one I need to replace with my field.

Can you please just post an example with the field I need to replace in each file. I'm going in circles and I am getting so frustrated. I rememer very detailed documentation here once and it seems to be gone. I just need a little help with this one.

I am so embarrassed to ask. Once I know where verythign plugs in I will be just fine.

Thank you

Allen

Posts: 12


AgentPhoenix Tue Jan 26, 2016 7:53 am

Re: Display a message key as a page.

The data array ($data) is just what's being passed to the view. You can set the variable in the data array to whatever you want. I just used message because it's simple, straightforward, and self-explanatory. All you need is to replace the key in the $this->msgs call to be the key of the message in the database you want to use.
User avatar

Posts: 7576


AlPrunty Tue Jan 26, 2016 2:13 pm

Re: Display a message key as a page.

AgentPhoenix wrote:The data array ($data) is just what's being passed to the view. You can set the variable in the data array to whatever you want. I just used message because it's simple, straightforward, and self-explanatory. All you need is to replace the key in the $this->msgs call to be the key of the message in the database you want to use.


Agent,

Please forgive once more I programmed professionally for years and message is a very common function not a variable... just to clarify as do I replace $this ??? or message. I just can't follow things as well as I once did. Most examples that make sense to me usually use $your_variable and that hits home every time.

I wrote an entire software package to monitor and maintain the population of a prison... it had an elaborate data dictionary of variables... but that was before the brain injury and sometimes I have problems following even the most basic things.

Allen

Posts: 12


AlPrunty Tue Jan 26, 2016 2:20 pm

Re: Display a message key as a page.

OK I can't get it to work. This is what I put in the

sim.php

Code: Select all

public function sim_writing()
{
$data['message'] = $this->msgs->get_message('sim_writing');
}



This is what is in my controller method...

in the viewer directory

sim_writing.php

Code: Select all
<?php echo $message;?>
[/quote]

it seems to have broken my sims menu altogether. I'm very confused... very frustrated and confused.

I really appreciate your help.

Allen

Posts: 12


AgentPhoenix Tue Jan 26, 2016 2:30 pm

Re: Display a message key as a page.

You still have to follow the tutorial for creating a page. With the controller the way you have it, it has no idea how to build up the template because you're not setting regions or assigning the regions to the template.

The location accepts an array of values. The keys of the array are turned into variables, hence why $data['message'] becomes $message in the view file.

Code: Select all
public function sim_writing()
{
    $data['message'] = $this->msgs->get_message('writing');

    $this->_regions['content'] = Location::view('sim_writing', $this->skin, 'main', $data);
    $this->_regions['title'].= "Writing Title";
   
    Template::assign($this->_regions);
   
    Template::render();
}
User avatar

Posts: 7576


AlPrunty Wed Jan 27, 2016 5:34 am

Re: Display a message key as a page.

AgentPhoenix wrote:You still have to follow the tutorial for creating a page. With the controller the way you have it, it has no idea how to build up the template because you're not setting regions or assigning the regions to the template.

The location accepts an array of values. The keys of the array are turned into variables, hence why $data['message'] becomes $message in the view file.

Code: Select all
public function sim_writing()
{
    $data['message'] = $this->msgs->get_message('writing');

    $this->_regions['content'] = Location::view('sim_writing', $this->skin, 'main', $data);
    $this->_regions['title'].= "Writing Title";
   
    Template::assign($this->_regions);
   
    Template::render();
}


Ah... thank you... I was plugging in my variable in all the wrong places and got confused. now the 'main' remains as 'main' instead of 'sim' since it's going on my sim menu right? I'll try it both ways this should get me going.

Allen

Posts: 12


AgentPhoenix Wed Jan 27, 2016 8:24 am

Re: Display a message key as a page.

Main is just saying that it's in the main section, not the admin or wiki sections. It's telling Nova which directory to look for the view file in.
User avatar

Posts: 7576


AlPrunty Sat Jan 30, 2016 7:02 pm

Re: Display a message key as a page.

AgentPhoenix wrote:Main is just saying that it's in the main section, not the admin or wiki sections. It's telling Nova which directory to look for the view file in.


So instead of two instances being sim_writing and one writing they should all be the same... I think I got it. Thanks millions.

Allen

Posts: 12


AlPrunty Sat Jan 30, 2016 7:13 pm

Re: Display a message key as a page.

I have a masters degree in information technogloy and before my Brain Trauma I used to teach at community college.

My key is defined in the middle tab messages.

My main.php controller has...

Code: Select all
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once MODPATH.'core/controllers/nova_main.php';

class Main extends Nova_main {
   
   public function __construct()
   {
      parent::__construct();
   }
   
   /**
    * Put your own methods below this...
    */
}
public function writing()
{
    $data['message'] = $this->msgs->get_message('writing');

    $this->_regions['content'] = Location::view('writing', $this->skin, 'main', $data);
    $this->_regions['title'].= "Writing Title";
   
    Template::assign($this->_regions);
   
    Template::render();
}


In my view named writing.php I simply have

Code: Select all
<?php echo $message;?>


I don't know why I just can't grasp something this simple... i'm at the end of my rope... can you just please show me what will work if my key is just writing. My PTSD is really hitting hard and I'm about to smash my computer against the wall.

Thanks so much and I really appreciate your help.

Posts: 12


AgentPhoenix Sun Jan 31, 2016 12:12 am

Re: Display a message key as a page.

The function has to be inside the class. You have it outside of class.
User avatar

Posts: 7576



Return to General

Who is online

Users browsing this forum: No registered users and 3 guests