如何使用多个内容类型的路由?

时间:2016-02-26 01:36:42

标签: bolt-cms

我尝试制作特定于内容类型的路线,例如the example in the bolt documentation

@interface MyScene()
{
    SKTexture* goldenCoin;
    SKTexture* blackCoin;
}
@property (nonatomic,strong) SKSpriteNode * randomCoinNode;
@end

-(id)initWithSize:(CGSize)size {
    if (self = [super initWithSize:size]) {
        [self AddRightColumnCoins:self.size];
    }
    return self;
}

-(void)AddRightColumnCoins:(CGSize)size{

   __block int counter = 0;

   _randomCoinNode = [SKSpriteNode new];

   SKAction *run = [SKAction runBlock:^(void){

            NSArray * coinArray= [[NSArray alloc] initWithObjects:goldenCoin,blackCoin,nil];
            NSUInteger randomIndex = arc4random() % [coinArray count];
            _randomCoinNode =[SKSpriteNode spriteNodeWithTexture:coinArray[randomIndex]];
            _randomCoinNode.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius: _randomCoinNode.size.width/2];
            CGFloat x = self.view.frame.size.width - ( _randomCoinNode.frame.size.width - 10 );
            CGFloat y = self.view.frame.size.height;
            _randomCoinNode.position = CGPointMake(x , y);
            _randomCoinNode.physicsBody.dynamic = NO;

            if( _randomCoinNode.texture == goldenCoin){
                _randomCoinNode.physicsBody.categoryBitMask = goldenCoinCategory;
            }else{
                _randomCoinNode.physicsBody.categoryBitMask = blackCoinCategory;
            }
            _randomCoinNode.physicsBody.contactTestBitMask = flappyCategory;
            counter++;
            [self addChild: _randomCoinNode];
            _fall = [SKAction moveToY:-50.0f duration:2];
            [_randomCoinNode runAction:_fall];

    }];

    SKAction *wait = [SKAction waitForDuration:0.6];
    SKAction *sequence = [SKAction sequence:@[run, wait]];
    SKAction *repeat = [SKAction repeatActionForever:sequence];
    [_randomCoinNode runAction: repeat];   
}

但是在多种内容类型上运行("页面"和"用户"具体而言)。

换句话说,我想做这样的事情:

pagebinding:
  path:           /{slug}
  defaults:
      _controller: 'Bolt\Controllers\Frontend::record'
      'contenttypeslug': page
  requirements:
      'contenttypeslug': 'Bolt\Controllers\Routing::getAnyContentTypeRequirement'

这个特殊的例子不起作用,在例如404时出现404错误pagebinding: path: /{slug} defaults: _controller: 'Bolt\Controllers\Frontend::record' 'contenttypeslug': page, user requirements: 'contenttypeslug': 'Bolt\Controllers\Routing::getAnyContentTypeRequirement' 未找到。

因此domain.tld/page, user/somepagedomain.tld/somepage都有效, 假设domain.tld/username是"页面的标记"记录,somepage是"用户"记录。

这可能吗?

1 个答案:

答案 0 :(得分:1)

简单回答:你不能。只有一种内容类型具有/{slug}

假设您有一个用户' x'和一个页面' x'。有人去了域名.tld / x',没有办法知道哪个是哪个。只需让用户拥有像/user/x这样的逻辑网址即可。