View Website

20 posts by 6 authors in: Forums > CMS Builder
Last Post: July 14, 2008   (RSS)

By Djulia - December 22, 2007

Hi,

I would like to obtain a specific value for : View Website >>

For example :

I have an editor (1) who has access to the folder News and another editor (2) which has access to folder FAQ.

It would be possible to give a different value for each editor?

Editor (1) : View Website >> == News
Editor (2) : View Website >> == FAQ

Thank you for your answer.

Djulia

Re: [Djulia] View Website

By Dave - December 22, 2007

No, it's not possible to have it link to different urls depending on which user is logged in.

A few options for you though. The simplest might be to create a publishedSections.html page with links to all the published sections. Then have the "view website" link point to that. That way all the CMS users could find their section.

The other would be the hack the /lib/menus/header.php file to show a different link based on the user. I could write some quick custom code up for you to do that if you wanted. But you'd have to re-apply it every time you upgraded or it would get overwritten.

Does either of those work for you? I think the first one would be the easiest, especially if you ever have a user who manages 2 sections.

Hope that helps! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] View Website

By Djulia - December 22, 2007

Hi Dave,

Thank you for your answer.

And with a condition ?

For example :

<?php if editor == 'name2' ?>
url 1
<?php elseif editor == 'name2' ?>
url 2
<?php endif ?>

Thank,

Djulia

Re: [Djulia] View Website

By Dave - December 22, 2007 - edited: December 22, 2007

If you are comfortable modifying the code, here's how:

- open /lib/menus/header.php
- search for $SETTINGS['websiteUrl'] and replace with $viewUrl
- add this code somewhere above it:

<?php
$viewUrl = $SETTINGS['websiteUrl'];
$username = $CURRENT_USER['username'];
if ($username == 'admin') { $viewUrl = "http://www.google.com/"; }
if ($username == 'dave') { $viewUrl = "http://www.yahoo.com/"; }
?>


Let me know if that works for you. :)

Edit: Fixed code (added $ in front of username)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] View Website

By Djulia - December 22, 2007

Hi Dave

I have just tested your proposal, but I have the error :
Notice: Use of undefined constant username - assumed 'username' in ...

An idea ?

Thank you,

Djulia

Re: [Djulia] View Website

By Dave - December 22, 2007

Ahh, I forgot the $ in front of 'username'. Sorry about that. Try this:

<?php
$viewUrl = $SETTINGS['websiteUrl'];
$username = $CURRENT_USER['username'];
if ($username == 'admin') { $viewUrl = "http://www.google.com/"; }
if ($username == 'dave') { $viewUrl = "http://www.yahoo.com/"; }
?>

Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] View Website

By Djulia - December 22, 2007

Hi Dave

It is perfect !!! [:)]

Thank you,

Djulia

Re: [Dave] View Website

By Djulia - July 10, 2008

Hi Dave,

I have a suggestion.

It would be possible to add a field "View Site" (websiteUrl) in the section User Accounts ?

It would be then possible to use a condition in header.php :

<?php if ($CURRENT_USER['websiteUrl']): ?>
<a href="<?php echo $CURRENT_USER['websiteUrl'] ?>"><?php _e('View Website &gt;&gt;') ?></a>
<?php elseif ($SETTINGS['websiteUrl']): ?>
<a href="<?php echo $SETTINGS['websiteUrl'] ?>"><?php _e('View Website &gt;&gt;') ?></a>
<?php endif ?>


Thank you for your answer.

Djulia

Re: [Djulia] View Website

By kevbarker - July 10, 2008

What I would like to be able to do is to have the 'View Site' be linked to the current page you are editing. That way when you click on it you can verify the changes/updates you just made to that section. Is that possible?

Thanks,

Kevin