Create New Page Variable for Page.php?

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 03-08-2010, 12:19 PM
New Pligger
 
Join Date: Dec 2009
Posts: 20
Hello,

I've been playing around with the variables found at: Page Variables
I've found out that for example "groups", "index", does work for their respective pages (groups.php, index.php etc). For example at groups it has the following working variable:
PHP Code:
define('pagename''groups'); 
$main_smarty->assign('pagename'pagename); 
And this above displays the groupname when viewing its page.

But for page.php, where the variable is:
PHP Code:
define('pagename''page'); 
$main_smarty->assign('pagename'pagename); 
It just doesn't work and "page" doesn't display anything! If changing "page" to "index" it works and displays the category name (i.e. news) but I would instead want it to display the name of the page (for example "about pligg").

I understand that variables would be connected to html1.php in /libs , and I've tried to replicate the variable for "index" to get it to work for "page" but I can't get it to work.

So now finally here is my question, how would I modify html1.php to create a variable that could be used for page.php to display the name of that specific page (for example "about pligg")?

Thanks very much for taking your time and helping me!

Best regards,
Jonas
Reply With Quote
  #2 (permalink)  
Old 03-08-2010, 12:53 PM
New Pligger
Pligg Version: 1.0.3
 
Join Date: Sep 2009
Posts: 19
Quote:
Originally Posted by Jonase View Post
So now finally here is my question, how would I modify html1.php to create a variable that could be used for page.php to display the name of that specific page (for example "about pligg")?
Page php is for general generating pages-- like goups, user page etc.

Every main php page have name variable changed with code example (topusers.php):
define('pagename', 'topusers');
$main_smarty->assign('pagename', pagename);

Do you need to crate new static page? if yes, you can do it in admin section "manage pages" or you can do it manually, but you would need to create new php page etc..(you have explanation on other forum topics about that)?
Reply With Quote
  #3 (permalink)  
Old 03-08-2010, 04:18 PM
New Pligger
 
Join Date: Dec 2009
Posts: 20
Sturko, thanks for your reply. I appreciate it!

I'm not referring to creating a static page, but instead to have the static pages created show their page name in the same way that the Index page displays "News" and category pages displays "News - Category".

In the example you provided with;
PHP Code:
define('pagename''topusers');
$main_smarty->assign('pagename'pagename); 
Here the text displayed would be "Topusers" or what its value is set at in html.php. But I can't get the static pages to display their pagenames. For example if I create a static page called "About Pligg". I would want it to display "About Pligg" just above the middle column and right column.

Thanks again and let me know if I should clarify further or post a screenshot.

Best regards, Jonas
Reply With Quote
  #4 (permalink)  
Old 03-08-2010, 06:39 PM
Yankidank's Avatar
Pligg Founder/Coder/Designer
Pligg Version: SVN
Pligg Template: Wistie
 
Join Date: Dec 2005
Location: Ocala, FL
Posts: 4,934
Send a message via AIM to Yankidank
I think I have some sample bits of code that will solve your problem. Pagename variables are usually for more general use, for your purposes you should use another variable like "posttitle". Posttitle is the title attribute that you assign to each page. On the page editor or submission page it is the first input line where it says "Page Title".

Whatever you enter into the page editor is your {$posttitle} value. So for example you can print the title of the page that you are viewing by doing this:
Code:
<h1>{$posttitle}</h1>
Now I realize that you may not want to use a title attribute for every one of these static pages. Now you can use an {if} statement like you do with pagename variables to determine if you are on a specific static page.
Code:
{if $posttitle eq "Sample Page Title"}
You are viewing the Sample Page Title static page
{/if}
You can use the sample code above in one of your template files that is called to generate the static page. If you are viewing the static page titled "Sample Page Title" it will print the message on line 2 of the sample code. The page title variable is case-sensitive, so make sure that you copy your page title exactly as you entered into the title field.

Combining the 2 Examples
Next is an example that combines the first 2 examples. The first line below will check if there is a {$posttitle} variable assigned. Basically it says "if the static page title does not equal blank, and the pagename variable is 'page', then do the following..." Because the {$posttitle} variable will not return as blank when you are on a page, it will print a <h1> tag on static pages with the page title. This example is going to be used in header.tpl in the breadcrumbs section starting with 1.0.4 because of this thread.
Code:
{if $posttitle neq "" && $pagename eq "page"}
<h1>{$posttitle}</h1>
{/if}

The Twitter Module for Pligg CMS!
Register, Login, and Submit Stories with Twitter. An absolute MUST HAVE for all Pligg sites!

Last edited by Yankidank; 03-08-2010 at 06:48 PM.
Reply With Quote
  #5 (permalink)  
Old 03-08-2010, 10:57 PM
Ascendancy's Avatar
Constant Pligger/Coder
Pligg Version: 1.2.0
Pligg Template: Custom
 
Join Date: Jan 2008
Location: Boston, MA
Posts: 131
Send a message via AIM to Ascendancy
I'm still curious about creating custom variables for these pages. Couldn't you create a Smarty variable for {pagesubtitle} or something like that? So {pagetitle} would hold the title of the page and {pagesubtitle} is another variable that's optional to set for static pages, and if it's set it'll display in an <h2> or <h3>.

I understand how to add that to a Pligg template, I don't know where to edit to create this variable. I would assume it's in html1.php based on this thread, but I've been digging around for a while on this topic and haven't seen it brought up

Pligg Developer for ~2 years
Snoggle News
Reply With Quote
  #6 (permalink)  
Old 03-08-2010, 11:30 PM
Yankidank's Avatar
Pligg Founder/Coder/Designer
Pligg Version: SVN
Pligg Template: Wistie
 
Join Date: Dec 2005
Location: Ocala, FL
Posts: 4,934
Send a message via AIM to Yankidank
My samples do not require you to edit any of the "core files" for Pligg, they are all code examples for Pligg template files. I demonstrated what you need to accomplish what you (Ascendancy) want to do, you just need to take a look at other template files to perhaps get a better grip on how to use this code to achieve what you are looking for.

The Twitter Module for Pligg CMS!
Register, Login, and Submit Stories with Twitter. An absolute MUST HAVE for all Pligg sites!
Reply With Quote
  #7 (permalink)  
Old 03-09-2010, 01:59 PM
New Pligger
 
Join Date: Dec 2009
Posts: 20
Yankidank, thank you very much! You solved it for me!

I had been looking at the wrong file to modify all along, the solution wasn't in the html1.php file but instead as you said in the header.tpl file and using the {$posttitle} code.
Here is exactly what I did, I went into header.tpl and added the following just at the start of breadcrumbs:
PHP Code:
{if $pagename eq "page1" }<h1>{$posttitle}</h1>{/if} 
Then whenever I would want a page to display its pagename (for example in story.php), I just add:
PHP Code:
define('pagename''page1'); 
$main_smarty->assign('pagename'pagename); 
Thanks once again, I'm very grateful!

Best regards,
Jonas
Reply With Quote
  #8 (permalink)  
Old 03-09-2010, 03:09 PM
Yankidank's Avatar
Pligg Founder/Coder/Designer
Pligg Version: SVN
Pligg Template: Wistie
 
Join Date: Dec 2005
Location: Ocala, FL
Posts: 4,934
Send a message via AIM to Yankidank
Jonase, I think you completely missed the point of my examples. You don't define a $pagename variable. Instead you should use a $posttitle variable for static pages.

The Twitter Module for Pligg CMS!
Register, Login, and Submit Stories with Twitter. An absolute MUST HAVE for all Pligg sites!
Reply With Quote
  #9 (permalink)  
Old 03-09-2010, 06:43 PM
New Pligger
 
Join Date: Dec 2009
Posts: 20
Yankidank, thanks once again for a quick reply.

As I understand it (although I'm new to working with tpl and modest in my PHP knowledge), is that in header.tpl I made a new statement where every page defined as page1 would have its pagetitle displayed (as per posttitle).
Then in story.php I defined it as page1 so that its pagetitle would be displayed.
It worked exactly how I wanted, but would it cause errors later on doing it the way I described above?

The thing is that just inserting
PHP Code:
<h1>{$posttitle}</h1
in story.php didn't work, so I did the above change instead.

Best regards, Jonas
Reply With Quote
  #10 (permalink)  
Old 03-09-2010, 11:36 PM
Yankidank's Avatar
Pligg Founder/Coder/Designer
Pligg Version: SVN
Pligg Template: Wistie
 
Join Date: Dec 2005
Location: Ocala, FL
Posts: 4,934
Send a message via AIM to Yankidank
I just don't understand why you are using $pagename variables. The last example that I provided would check if the $pagename is the story.php page (used to generate static pages), and the second bit checks to see what the name of that page is using the $posttitle variable. I guess you can use whatever you think works for you, but I don't want to confuse other people. Your posts are confusing me because I'm not sure what it is exactly that you are trying to do.

The Twitter Module for Pligg CMS!
Register, Login, and Submit Stories with Twitter. An absolute MUST HAVE for all Pligg sites!
Reply With Quote
Reply

Tags
html1.php, page variable, variable

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page Variables Yankidank Wiki Articles 3 05-19-2011 09:21 AM
I want create a new Page in Pligg Ver-9.9.5 gaurangitech Questions and Comments 2 09-02-2009 10:49 AM
How to create Page Links in Menu & Subpages graham414 Questions and Comments 0 08-20-2009 03:19 PM
Can't create new page or install module in Pligg RC4 blueven Questions and Comments 0 04-12-2009 11:37 PM
How to add comments to new Pages, create custom feedback page mrigank Questions and Comments 2 02-23-2009 01:07 AM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development