Jump to content

Page Add step not being skipped when Name format for children is set...


hellomoto
 Share

Recommended Posts

For my event template I have tried setting the Name format for children as title and date, respectively, as those are the only two I've ever gotten to work with that. So I do have a small module that renames them before save, to Y-m-d-title, but I can't manage to get adding an event from the admin the standard way to skip the Page Add step with the Title and Name generation. Not only that but it always displays the warnings for Name Already taken, which I don't want, as they're organized by date... Admin users don't need to see "The name entered is already in use. If you do not modify it, the name will be made unique automatically after you save.". How can I bypass this? Thanks.

Link to comment
Share on other sites

Having a similar scenario here and would also like to know how to avoid that message for the backend.

Would you mind sharing your small module here?

I think we'd need a hook before page render in that module which unsets that specific notification.

EDIT: Can't seem to find much documentation for working with the notification system from the API side. Looking at Ryan's post here it seems that notifications are tied to the $user object?

Link to comment
Share on other sites

My Small Module:

class CalendarEventsCustom extends WireData implements Module {

	/**
	 * getModuleInfo is a module required by all modules to tell ProcessWire about them
	 *
	 * @return array
	 *
	 */
	public static function getModuleInfo() {

		return array(
			'title' => 'Calendar Events Custom', 
			'version' => 1, 
			'summary' => 'Renames subevents',
			'href' => '',
			'singular' => true, 
			'autoload' => true, 
			'icon' => '', 
			);
	}

	public function init() {
		$this->pages->addHookBefore('save', $this, 'nameEvents');
	}

	protected function nameEvents($event) {
		$page = $event->arguments[0]; 
		$sanitizer = wire('sanitizer');
		if($page->template == 'calendar-event')
			$page->name = wireDate('Y-m-d',$page->calendar_event_start) . '/' . $sanitizer->pageName($page->title, true);
		elseif($page->template == 'calendar-event_instance')
			$page->name = wireDate('Y-m-d',$page->calendar_event_start);
		// if calendar_start_date != rrule don't publish

	}

}

It'll probably be of no help to you, and anyway as it turns out, of course I was just confused and checking the wrong parent template's settings. Name format for children was not set where it was supposed to be.

If you want to disable a certain notification then it sounds to me like you're on the right track... What message are you trying to get rid of?

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...