michelangelo Posted June 23, 2020 Share Posted June 23, 2020 Hello guys, I have made a small website that has a few thousand pages with several fields. It all works fine, but when I change my language they don't show up... I found out in the depths of the forum that they need to be activated. Is there any way to do it as a batch process instead of doing in by hand? Just to clarify, what I need to change is in the Settings of each page, not a field in my template. This 'Active?' button needs to be ticked on every page. I thought maybe Lister might do the trick, but I can't seem to find a way to affect this Name field. Thank you! p.s I am using ImportCSV module to load them up, which works great but I don't think it can apply this setting for me. Link to comment Share on other sites More sharing options...
MoritzLost Posted June 23, 2020 Share Posted June 23, 2020 Yes, the "Active" checkbox under the settings tab controls whether the page is viewable in that language. When you create a page through the CMS, it is active in all languages by default. But if you create a page through the API, it is inactive in all non-default languages by default (I've stumbled upon this as well a couple of times, not sure what the resoning behind that is). You can set the active status through the API, the property is "status{$id}", where {$id} is the ID of the language you want to activate the page in. For example, this code will iterative over a set of pages and activate them in all languages: $importedPages = wire('pages')->find('template=imported-page'); // adjust the selector as needed foreach ($importedPages as $p) { foreach (wire('languages') as $lang) { if ($lang->isDefault()) continue; $p->of(false); $p->set("status{$lang->id}", 1); $p->save(); } } You can put this somewhere in a template file and reload the page once, or execute it through the Console provided by Tracy Debugger. Of course, if you are importing manually or can use a hook to modify the behaviour of your import module, you can also set this property at the time of importing. 4 Link to comment Share on other sites More sharing options...
michelangelo Posted June 23, 2020 Author Share Posted June 23, 2020 Thank you @MoritzLost! It's brilliant! It took me a few tries as my server was timing out, but it seems to work flawlessly. 1 Link to comment Share on other sites More sharing options...
adrian Posted June 23, 2020 Share Posted June 23, 2020 @michelangelo - the AdminActions module also has an action for this: 1 Link to comment Share on other sites More sharing options...
michelangelo Posted June 23, 2020 Author Share Posted June 23, 2020 Wow, super nice! The more you know... Thank you! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now