1 users online. Create an account or sign in to join them.Users

Search

[EDIT] I changed the topic, since it was kind of missleading

Problem: I'm currently working on a real estate site and there is, of course, a section called 'immobilie' (real estate).

My customer wants to be able to mark entries as reference, so they would be appear on a reference page.

No problem:

create a datasource and filter entries by reference is checked or not.

Big Problem:

References should be manually sortable.

I hoped, that there's an extension that would auto create entries e.g when saving one entry and certain criterias are met. That would solve the sorting issue.

Is it, generally speaking, possible solve this with a custom extension? Or is there a better/easier way and I' totally off the track?

Kind Regards, Thomas

Ok, I think a custom extension would be the easiest way to do this.

I'm not done yet, since I haven't figured out what is the best way to update and delete entries from within a delegation method.

This is a rough concept of what I want to do

public function getSubscribedDelegates(){
            return array(
                    array(
                        'page' => '/publish/edit/',
                        'delegate' => 'EntryPostEdit',
                        'callback' => 'autoAddEntry'
                    )
            );
        }

    public function autoAddEntry($context){

        if(array_key_exists('save', $_POST['action']) || array_key_exists("done", $_POST['action'])) {
            $cont = $this->_Parent->Page->_context;
            if ($cont['section_handle'] == 'immobilie') {

                $entry_id = $cont['entry_id'];

                # check if reference is set
                if ($_POST['fields']['reference'] == 'yes') {                       
                    $fields = Array(
                        'titel' => $_POST['fields']['titel'],
                        'bilder' => $_POST['fields']['bilder'],
                        'ref_id' => $entry_id,
                    );

                # check if there is an entry of 'Referenz' where ref_id equals entry_id
                    $ref = ''; // 'Referenz' entry exists
                    if ($ref) {
                        // update entry
                    } else {
                        // create new 'Referenz' Entry
                    }
                # field 'reference' is unset
                } else {
                #  check if there is an entry of 'Referenz' where ref_id equals entry_id    
                    $ref = ''; // 'Referenz' entry exists
                    if ($ref) {
                        // delete 'Referenz' entry
                    }
                }
            }
        }
    }

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details