Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another unprotected pages in private gallery #1066

Closed
Mates-K1 opened this issue Oct 7, 2019 · 15 comments
Closed

Another unprotected pages in private gallery #1066

Mates-K1 opened this issue Oct 7, 2019 · 15 comments
Labels

Comments

@Mates-K1
Copy link
Contributor

Mates-K1 commented Oct 7, 2019

I have private gallery.

Is there any way to set some of page (which I created) and all News public?

@sbillard
Copy link
Contributor

sbillard commented Oct 7, 2019

You can un-protect the index page. I can add the news.php script to the list of scripts that can be unprotected. Any control of what is then displayed would be up to the theme scripts.

@Mates-K1
Copy link
Contributor Author

Mates-K1 commented Oct 7, 2019

Thanks.

Now my unprotected pages are:

  • contact.php
  • home.php
  • inc_footer.php
  • inc_header.php
  • inc_print_album_thumb.php
  • inc_print_image_thumb.php
  • inc_print_news.php
  • index.php
  • register.php

And what about custom pages (pages which I created)? May be you said it in last sentense, but for me it remained lost in translation.

@sbillard
Copy link
Contributor

sbillard commented Oct 7, 2019

You do not need to unprotect the "inc_" pages, only pages that are directly loaded by URLs

@sbillard
Copy link
Contributor

sbillard commented Oct 8, 2019

Any custom script you make should show up in the list of pages that can be unprotected.

sbillard added a commit to sbillard/netPhotoGraphics-DEV that referenced this issue Oct 8, 2019
@Mates-K1
Copy link
Contributor Author

Hmmm... I dont know how to make/add custom script to show up those pages unprotected.

Can you direct me how to do it please?

@sbillard
Copy link
Contributor

sbillard commented Oct 15, 2019

With the current development release your news can be un-protected by simply checking the news.php script in callery options/unprotected pages.

Showing specific CMS pages is a bit more complicated. You would start by making a copy of the theme pages.php script, maybe call it "public_pages.php" and unprotect that script. You will have to decide how you are going to link to these custom pages. Perhaps a custom menu item? Anyway, the link will need to pass the page titleLink in a query parameter. Then public_pages.php will have to instantiate $_CMS_current_page = newPage($titlelink); Where titlelink is the string you passed.

You may well want to make other modifications to public_pages.php. Things like breadcrumbs may not make any sense. Even if they did, they would invoke the protected pages.php script so would not work.

You might want to consider making you site "public" but password protecting anything you do not want shown. Might be a simpler task.

@Mates-K1
Copy link
Contributor Author

Many thanks. I will try it.

If gallery is public and albums are protected - is there only one password or users can have different passwords?

@sbillard
Copy link
Contributor

Registered users will be able to view the albums when they are logged in. But I also have another thought that I need to research. There is a filter that might let you decide what to show and not to show.

@sbillard
Copy link
Contributor

sbillard commented Oct 15, 2019

So, you can do all this with a filter. In your theme's functions.php add the following code.

`
npgFilters::register('isUnprotectedPage', 'test_protection');

function test_protection($allow, $page) {
switch ($page) {
case 'pages':
global $_CMS_current_page;
return in_array($_CMS_current_page->getTitleLink(), array('all-things-npg.htm', 'npg-architecture.htm'));
case 'news':
return true;
break;
}
return $allow;
}
`

For the array list the titlelinks of the pages you wish to allow to be viewed. This will allow all news articles and the selected list of pages to be publicly viewed. If you wanted to restrict the news, you could do a similar test on the news category of the article.

@Mates-K1
Copy link
Contributor Author

Woooorks!!! Yeah, you are programming God!!!

Many thanks!!! 🥇

@Mates-K1
Copy link
Contributor Author

Is possible to make it as plugin or standard part of nPG so I don't need to edit theme after every update?

@sbillard
Copy link
Contributor

Sure. To make it a plugin, just put the code in a separate file in the plugins folder. You will have to add the plugin header stuff: Look at the demoplugin for what you need.

@Mates-K1
Copy link
Contributor Author

👍
(I cant find demoplugin :( , I looked to another plugins)

I wrote to nPG forum, can you check it please?

@sbillard
Copy link
Contributor

@Mates-K1
Copy link
Contributor Author

Thanks. For me, you can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants