by
KK » Sat Jan 21, 2023 5:25 pm
Perhaps this kind of manipulation can also be done by processing the page being saved *twice*? -
first let Couch save it the standard way and then immediately after that edit the newly saved page and change it anyway that is desired (renaming it with count, e.g. as in your case).
If this sounds reasonable, one way of achieving it would be to override the full form that Couch uses while saving pages (@trendoman has a complete list at
viewtopic.php?f=8&t=13119).
'Advanced theming' on
viewtopic.php?f=5&t=10241 has details about it and
viewtopic.php?f=2&t=10438&p=25693#p25696 has a real life example.
Most of the code mentioned in the last link above is already a part of Couch now so you only need to activate the 'sample' theme and copy 'couch/theme/_system/content_form.html' into 'couch/theme/sample' folder. To make Couch use this snippet for only one particular template, rename it by suffixing the template's name to it (as explained in the above-mentioned post e.g. if the template is 'service.php', the snippet should be named 'content_form_service-php.html').
And now we can play with the save process -
the original code immediately redirects after a successful save
- Code: Select all
<cms:db_persist_form
_invalidate_cache='1'
_token=k_cur_token
/>
<cms:if k_success >
<cms:if k_redirect_link >
<cms:set_flash name='submit_success' value='1' />
<cms:redirect k_redirect_link />
</cms:if>
</cms:if>
We can try re-editing the newly saved page and renaming to something else e.g. as follows (here only adding a '-xxx'; you can device your own format) before the redirection -
- Code: Select all
<cms:db_persist_form
_invalidate_cache='1'
_token=k_cur_token
/>
<cms:if k_success >
<cms:if k_cur_form_mode eq 'create'>
<cms:pages masterpage=k_template_name id=k_last_insert_id show_future_entries='1' limit='1'>
<cms:db_persist
_masterpage=k_template_name
_mode='edit'
_page_id=k_page_id
k_page_name="<cms:show k_page_name />-xxx"
k_page_title="<cms:show k_page_title /> xxx"
/>
</cms:pages>
</cms:if>
<cms:if k_redirect_link >
<cms:set_flash name='submit_success' value='1' />
<cms:redirect k_redirect_link />
</cms:if>
</cms:if>
Does this help?